Is it a good idea to improve on answers to your own question, once you know more about the topic?
I think, no.
If you asked a question and got the answer, it's fine.
If it's just a small change, it's outside of this this site to update the answer to fit some specific requirements which are not important for the others reading this answer.
If the change is significant, it's incorrect to make an edit anyway. You need to post a new answer.
And an answer to a bit different question
I've raised a question getting and accepting an answer.
Making my own tests I've found a couple of cases where the code does not work as expected and corrected it.
My solution is the accepted answer with a couple of modifications and I want to give the rep to user that posted it. But also, if someone find the answer in the future, will have a buggie code...
You should write it in comments to answer first.
If comments are ignored and you can and need to correct the answer, you can do it.
code will be so long to be a comment
In this case you can temporary place the code somewhere else (patsebin, for example).
or will make answerer to rewrite itself the code when I already did it....
I don't know anything about you skills level, but anyway, this is meta so the answer should be considered correct for all case, so let's assume following situation:
- How to calculate number of trailing zeroes in factorial of
n
?
- That's the code [and this code calculates wrong for all powers of 5]
- There is smth wrong, and that's the fix:
if (n==5) return 1;
Whould you like to see such edit of your post without any comments?
As the fix really hides the original error without fixing it, such fix makes answer worth, not better.
So I think, the correct way is to inform first.
If you fill fix will take a lot of efforts, just show your version.
PS: By the way, the example with factorial incorrect for powers of 5 except if (n==5) return 1;
is taken from some book - it was published as a correct solution.