5

Could someone please clarify why on earth is this edit rejected because:

This edit is incorrect or an attempt to reply to or comment on the existing post.

?

7

I'm sorry your edit was rejected. It was perfectly correct. The original poster even made the same change a few hours later (he was notified of your edit, but too late to do anything about it).

It is generally a bad idea to edit code in questions on Stack Overflow, because you might inadvertently fix the problem code that the asker was facing. This reasoning only applies to questions, not answers.

The official guidance on editing states (excerpted):

When should I edit posts?

Any time you feel you can make the post better, and are inclined to do so. Editing is encouraged!

Some common reasons to edit are: (…)

  • to correct minor mistakes or add addendums / updates as the post ages

Correcting a typo in code absolutely fits the bill.

Unfortunately there are a few users who frequent Meta Stack Overflow and saw a guideline not to edit code in questions, but stopped reading in the middle. Don't let them stop your good work.

|improve this answer|||||
  • 1
    While it is certainly correct that you can edit code in answers, it is important to maintain the author's intent when editing. Here the intent of the author is clear, and the edit is fixing it. Were the edit to change code the clear intent of the post/code, even if you personally felt that it is better, then that is not an appropriate edit. Such situations should result in a comment or another answer. – Servy Jan 7 '14 at 21:10
  • 1
    @Servy Yes, of course, but that applies equally if you edit text, it isn't specific to code. – Gilles 'SO- stop being evil' Jan 7 '14 at 21:34
  • Indeed it does. I was simply clarifying the point as it is probably the most common valid reason for rejecting code edits, and it's a confusing point worth emphasizing. – Servy Jan 7 '14 at 21:37
-3

If you have asked about the rejection of this edit suggestion then here is the reason:

You tried to change the original post by replacing a variable with another variable, which is highly discouraged by the Stack Overflow community. Best approach is to add a comment mentioning that the code has issues and what is the correct code. Let the original poster see your comment and then he/she may decide to edit the post himself/herself.

Editing should be done to improve the post like formatting, correction of language, etc. Editing should not be include any changes which modifies the content of the original post.

|improve this answer|||||
  • but seeing from the code don't you think it's fairly obvious that OP's intended variable was submission rather then temp and that it was kind of a copy-paste error? – Bleeding Fingers May 10 '13 at 7:23
  • Sure, it could very well be a copy-paste error but generally acceptable guidelines for Stack Overflow states that we should add a comment mentioning this fact. – Aziz Shaikh May 10 '13 at 7:31
  • so where can I find those guidelines? The only formally place where I could was while actually editing it, in the "How to Edit", and it stated "correct minor mistakes". Now the question is. – Bleeding Fingers May 10 '13 at 7:58
  • @hus787 the dominant stance is that code is almost taboo. You can fix obvious typos in answers (int temp = *a; *a = *b; *b = tmep; for example), although some may reject even that, but beyond that, people rather reject correct code fixes than let incorrect changes pass through. – Daniel Fischer May 10 '13 at 9:13
  • When should I edit posts? – Aziz Shaikh May 10 '13 at 9:42
  • Also see the 2 answers for this similar post – Aziz Shaikh May 10 '13 at 9:50
  • 1
    It may be that the typo in the code is the actual problem and if you edit it out, then people trying to figure out what's wrong will not see the typo in the original code. – Ren May 10 '13 at 10:09
  • 5
    Nonsense. This was an obvious typo in an answer. It's only changing code in questions that's highly discouraged, precisely for the reason @Ren mentions. This reason does not apply to answers. If you see a minor mistake in an answer, be it in code or not in code, correct it — it's right there in the official guidance. A comment is the right thing when you're unsure (to request clarification), but if you know how to fix the code, then a comment is wrong (comments are only for transitory things), you should edit. – Gilles 'SO- stop being evil' Jan 7 '14 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .