But I don't understand, why was this suggested edit rejected by the community?
I'll usually reject suggested edits that change code unless there's a good reason not to. It's very easy to change the meaning of an answer unintentionally with even small code changes.
The only reason I approved your suggested edit was because:
- The change was trivial and unlikely to introduce an error (removal of an entire return statement).
- There was supporting evidence in the accepted answer on the question that the post you edited had meant to override a void function.
Often when people are reviewing edits, they don't have any context other than what is in your comments on the edit. I believe yours were something like "void functions can't return a value". Without context, it's hard to know if the overridden function (OnBackPressed) should have been declared as void or bool.
You may have had similar changes accepted in the past however because some people are significantly more likely to approve an edit than reject one, so there's also an element of luck/timing involved...
If you look at the "how to edit" block shown when you suggest an edit, you will notice it shows the following points:
- fix grammatical or spelling errors
- clarify meaning without changing it
- correct minor mistakes
- add related resources or links
- always respect the original author
None of those points is about code, but somebody could argue that changing the code you are changing the answer given from somebody else.
I would generally suggest to avoid editing the code given in a post. If there is a typo in the code, I would write a comment letting the user who wrote the post know that; if the answer is suggesting using a function, and I believe there is a better function to use, I would write a comment about that.
In the case you think the code is completely wrong, or there is alternative that could be used, then you should write your own answer, rather than editing the answer given from somebody else.
This is very clearly a good edit that should have been accepted. I'm sorry for the reaction you got.
This is a textbook case of a good edit:
- It fixes a small mistake in an otherwise good answer.
- The edit summary explains the mistake.
- The mistake is easy to verify: indeed,
return truecannot work for a method whose return type is
void, and anyone who is familiar with a large number of C-like languages (C, C++, Java, C#, etc.) can spot that.
The rules for editing state this clearly:
When should I edit posts? (…)
- To clarify the meaning of the post (without changing that meaning)
- To correct minor mistakes
This is a minor mistake being corrected. The meaning of the post isn't changed: it's just a code example that was made correct. The original author was respected: after you pointed out the problem to him in a comment, he went and made the exact same change.
I'm sorry that your valuable contribution was rejected. Sadly, this is an old problem on Stack Overflow — reviewers who reject edits in direct contradiction with the rules and core values of Stack Overflow. Please keep up the good work nonetheless.