Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I know that we shouldn't edit code in questions, for obvious reasons. But what about code in answers? Does the same rule apply?

In this case, the code in the answer was changed by an edit to reflect what the author wrote in the text, but I believe that this is not was the author meant. The edit changed the code to something that wouldn't even compile, and after that, downvoting started. As I see it, an edit should make the answer more correct, not introduce further errors.

Wouldn't it have been better to add a comment suggesting the changes? Should this edit be reverted?

I could at least edit it to use Integer instead of int, but that would still change the code, and I am not sure if I should do that.

Since this wasn't really an edit problem, but a problem with html rendering, I'll add a picture of what was presented here:

Edit view diff

On hindsight, added 6 characters in body would have been a hint.

share|improve this question
up vote 6 down vote accepted

The edit just code-ified the unformatted code. If you look back at the source of the original post, it read:

This means that the ArrayList consists of objects that are of type Number.

Since the value you are trying to add is of type int I'd recommend you to change:

private ArrayList<Number> list;


private ArrayList<int> list = new ArrayList<int>();

See how the code isn't indented with four spaces? The original post did indeed have the incorrect ArrayList<int> bits. But unindented, this renders as:

This means that the ArrayList consists of objects that are of type Number.

Since the value you are trying to add is of type int I'd recommend you to change:

private ArrayList list;


private ArrayList list = new ArrayList();

The <Number> and <int> parts are interpreted as HTML tags and become invisible. It looks like the original poster just wrote code without generics, but it's actually improper Markdown formatting!

share|improve this answer
I am sure it didn't, because I have seen it right when it was posted, and I see private ArrayList list = new ArrayList(); without <int> in the diff. I am slightly confused :) – Modus Tollens Jan 10 '13 at 1:30
@KatjaChristiansen: the parser interpreted <int> as an invalid HTML tag and removed it during the page rendering. You can view the original source here:…, or click the "side-by-side markdown" button in the revision list. – Shog9 Jan 10 '13 at 1:31
I see, this makes sense. That was the reason I didn't see it in the first place. Thanks! – Modus Tollens Jan 10 '13 at 1:33

First off, as John notes the editor in this case didn't break anything - the answer was broken from the get-go, and the edit just made it render properly.

Beyond that, any edit that improves a post is generally a good one, but always try to respect the original author: if you find yourself writing something he might have cause to disagree with, post your own answer.

As for what you should do when you come across something like this?

  • If you see a truly malicious edit, roll it back.
  • If you see an edit that makes a post worse, roll it back.
  • If you see an edit that improves a post, but leaves it with outstanding problems - fix those problems.
share|improve this answer
In this case, the edit didn't exactly improve the answer: new ArrayList<int> doesn't compile. Integer would have been correct. – Modus Tollens Jan 10 '13 at 1:28
@Katja: yes, but the original author didn't write ArrayList - he wrote ArrayList<int> but neglected to mark it up. Sometimes, respecting the author means respecting his right to be wrong. – Shog9 Jan 10 '13 at 1:29

You must log in to answer this question.

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