The cardinal rule when deciding whether to edit is: Will my edit make the Internet a better place?
If you have a small correction or addition that improves an answer, go ahead and do it. Leave a clear explanation of why you made the change in the edit log; never put “edited by” or “I needed to fix this line” inside the answer.
“Did not have an answer for a small sub part” sounds like a valid reason for editing a priori (of course, it then comes down to each individual case). Some more guidelines:
- Do not edit if you're not absolutely sure your edit is more correct than the original. Comment instead.
- Do edit if you're adding an objective piece of information to an objective answer, where that information is a complement that's generally useful for the audience (e.g. to add a link to a standard reference for a library that the answer mentioned in passing, or a Wikipedia link if you had too look up a concept to understand the answer).
- Do edit if something in an answer is wrong, but it's only a small part that's easily fixed (e.g. a syntax error in code that was obviously typed directly into the browser).
- Do edit if something in an answer is dangerous (e.g. an SQL injection) and can be fixed locally (i.e. by adding a few quotes or a function call in the right place).
- Do respect the overall tone and style of the answer.
- Do not edit around a subjective judgement or recommendation.
- Do not edit if a fundamental premise of the answer is wrong; instead, comment, downvote and write a competing answer.
- Do not edit just to add a complement that would be useful only to very few users, or that isn't directly related to the question and answer (e.g. “I had to install jQuery first, but then it worked”).
(For example, feel free to edit this answer if there's a spelling error. But if you disagree with my guidelines, which are subjective, comment, downvote if you disagree enough, but don't edit it. Don't edit it if the boldface abuse bothers you¹, it's part of the style.)
¹ Though to be honest I do feel I've overdone it.