8

I'm trying to post a sample of code that looks like this:

enter image description here

Look at all of those comments, and it still won't allow me post! What am I doing wrong?

2
  • 10
    comments are code
    – go-oleg
    Jun 19, 2013 at 3:39
  • Why is this downvoted?
    – raam86
    Jun 19, 2013 at 5:51

5 Answers 5

18

In Stack Exchange sites anything within a code bock is treated as code. All it is asking is to add detailed text (text that is not in code blocks) to your question.

9

Comments in the code are still considered code.

What they're after is some text to explain the code, something like in this and the preceding paragraph.

// Not stuff like this which is a code comment :-)
4

Ideally, you'd add as much clarification and context as you could outside the code block, since you're no longer constrained to mixing code and meta-information about the code.

From a cursory examination of your screenshot, the comments appear to be inserted by a TA or instructor as part of a course you're completing, and are probably not particularly relevant to your question. Remove them, and summarise the necessary details outside the code block.

1

In your above mentioned image it displays clearly that it only contains only code, and as paxdiablo said Comments in the code are still considered code.

You have to post only relevant code in your question not the unnecessary things like(comments) with it. Also what problem you are facing and the explanation of desired output should be added in your question as detail.

1
  • I believe he asked the question he did so he could figure out how to better ask his real question later.
    – chancea
    Jun 19, 2013 at 4:22
0

When I read a question, I usually read all of the text first, skipping the code. Then when I have understood the context, I go back and examine the parts of the code that relate to the question.

If the comments are inline, they often go unnoticed. For this reason, it may help readers of your question to place the problem description outside the code block itself.

Additionally, consider the fact that we often are asked to troubleshoot code that is not exactly like the original, real-life code. This code has been modified by the OP in an attempt to bring clarity or simplicity. In many cases, it simply obscures the problem or introduces new ones. If you are modifying your code to add the comments before posting it here, you are presenting code that doesn't match your real-life situation. If your edits modify the functionality of the code in any way (even accidentally) they may make answering more difficult.

You must log in to answer this question.

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