45

Check this question.

Immediately after posting it, I found that I had a mistake in the code.

But still I feel someone else (new to Laravel) may do the same mistake.

So which one would be better? Shall I delete this question? Or keep the question live by thinking it would be helpful for others?

6
  • Is the mistake the cause of your question or it is unrelated?
    – Braiam
    Commented Apr 23, 2017 at 12:22
  • 15
    I'd say keep it, since it isn't just a typographical error (so it's not off-topic), especially if you think other people might make the same mistake. Just post your solution as an answer and possibly explain it a little bit.
    – Keiwan
    Commented Apr 23, 2017 at 12:47
  • 48
    The rubber ducky strikes again. Being forced to write a clear question is often enough for a programmer get enough insight in the bug to help him solve it by himself. Whether you keep it is your judgement call but if you do then you must at least write the answer. Commented Apr 23, 2017 at 14:04
  • 3
    Thanks for your comments. I felt that someone may need this in future. So i kept the question and answer it myself with the description i came to know.
    – siddiq
    Commented Apr 23, 2017 at 14:12
  • 4
    @HansPassant I think I found more solutions on SO by just writing the question and realising the solution myself, than by actually waiting for someone's answer
    – Dunno
    Commented Apr 24, 2017 at 12:17
  • Keep the question but change the angle of the question to "How to avoid this (typical) mistake". But I recommend that you also argue for why this might be a common mistake. Commented Apr 30, 2017 at 17:55

4 Answers 4

63

You asked the question. You found the answer. So answer your own question and accept your own answer. It is totally allowed if you genuinely found the answer yourself. (Note: Answer the question if this solves the problem, not add it as a comment - but I see you have done already :)

2
  • 35
    If the error is a typo error, or if the question is not very relevant, I would prefer deleting it instead of answering.
    – Mistalis
    Commented Apr 24, 2017 at 12:19
  • 7
    @Mistalis I'd say unless it's the sort of typo that could come up a lot, single quotes instead of double quotes, that sort of thing. Commented Apr 24, 2017 at 14:01
13

Answering your own question if you figure out the problem yourself is not only allowed but encouraged. In fact, the only two questions I've ever asked on SO I've answered myself. You might notice there's a checkbox when composing your question that allows you to immediately answer your own question, with a link to this SO blog post. So, given that the site explicitly added a feature allowing you to do it, yes. You should answer your own question.

Your reasoning is completely correct -- the whole reason for doing it is so that you can help others in the future and avoid situations like the one in this XKCD where you find an ancient comment saying something like "nvm solved it lol" and you leave unsatisfied. And, even if you're feeling selfish, you should still do it since you're liable to gain some rep if others find your self-answer useful (on one of my self-answered Q's, the answer has more total score than the question, oddly enough).

4

I often find questions like that when I'm googling how to actually even use some API or function.

So answering your own question with working line of code might help people who don't even know how to write the piece of code you started with when asking the question. And if you feel like adding details, that never hurts.

-44

I think you should keep the question and add a comment with the answer, because there's a good chance that some one in the world might have the same question.

3
  • 37
    If solves the problem it should be an answer, not a comment
    – Adam
    Commented Apr 24, 2017 at 10:08
  • 5
    Please don't answer questions in comments (or if you do, post it as an answer as well), when I'm looking for unanswered questions this adds false entries, a surprising number of unanswered questions are really just questions where a comment solved the OP's problem. It puts me in a weird position where I have the answer but I don't want to "bump" the (answered in comments) post, so it pretty much just stays "unanswered"...
    – jrh
    Commented Apr 24, 2017 at 11:23
  • 3
    @jrh Meta consensus seems to be go for it! IMO stack overflow gets anough traffic that bumping isn't a huge nuisance anyways.
    – user812786
    Commented Apr 24, 2017 at 14:09

You must log in to answer this question.

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