I reject the currently accepted answer and would present a (nearly) opposite opinion.
Yes, you should add explanations to code-only answers, when you believe the code is not self-explanatory, or when readers would benefit from a natural-language explanation of what happens in the code.
Edits serve different purposes, not only a clarification of the poster's intent. And while a poster has "primal" rights on their post - once it is published, it is a community resource, and should be polished and improved if possible. If an author didn't explain, you are communicating your explanation, not theirs, with your edit - but this is ok, as SO is a collaborative Q&A platform. We improve and rephrase questions, and answers, all the time. It does not matter than your edit might be interpreted as "rewarding a poor post" - rewarding or penalizing user actions is ever a secondary goal to curating more-useful questions and answers.
The exception to the above is when your prospective edit would go against the poster's intent, or is clearly separate and distinct from the original answer; in such cases, a different answer should be posted, and the post should not be edited to make such a change.
It is of course legitimate to downvote and/or comment on a post lacking a proper explanation; and many people prefer doing that. But helping out by adding the explanation is just as legitimate; and if the original poster believes the edit is not in-line enough with their intent, they can alter it, or at worst, remove it - and that is also legitimate.
PS:
- When making significant additions to a post, like an explanation of a code-only post, make sure you avoid editorialization, jokes, cultural references, examples from your own personal experience, etc. While those may be appropriate for your own post, they are less/not appropriate for posts originally by someone else, even when the post is marked as having been edited, as they are too likely to diverge significantly from the author's intent.
- @anatolyg gives the useful advice of waiting a while before adding explanations, as the original author might be planning on doing just that.
I have a banana
. Now explain whether this is due to an apple shortage or a banana surplus.Knife.Slice(banana, 1, 6)
. If that was all the answer was can you tell me what Knife.Slice does? Presumably it splits a banana, but what do the parameters do? An edit to add that info is useful. Edit: "Knife.Slice takes the item you want to slice, how many of them and how many pieces you want each sliced into. In this example it would return an array of 6 BananaSlices. You can read more here: official docs"