This happens quite a lot for me lately. I encounter a problem in my code, I want to ask it here and while I type the question, I have an idea which proves useful. I think that this question might interest other people, but it feels kind of duchy to ask a question just to answer it. Should I?
But before asking make sure you have searched and the question is not a duplicate.
The reason for asking and answering questions is not just because of your self but also because of other users that will visit the site in future
EDIT : Take a look at How to ask
Make it relevant to others
We like to help as many people at a time as we can. Make it clear how your question is relevant to more people than just you, and more of us will be interested in your question and willing to look into it.
The site has a "self learner" badge for anyone who answers their own question and receives three upvotes. (Unlike some others, this badge will not be awarded more than once per site.)
Basically, the site rewards you for asking, then answering, a question that bothered you, if enough (three) others deem that the question-answer sequence was useful.