Say you've thought hard about a specific issue in your research and have elaborated a possible answer, interpretation, etc., to tackle it. (I'm not thinking about huge research subjects, but rather small ideas that articulate a demonstration.) You then discover later on, while reading a new paper, that someone has thought about the exact same thing. How do you present your idea on the issue?
On the one hand, you can't pretend that you haven't read what the other paper says about it, both for reasons of intellectual honesty and because the other author (or someone who read his paper) might think that you stole his idea. Citing the other paper is thus somewhat of an obligation.
On the other hand, it doesn't feel right to dismiss your demonstration and just cite the other paper, since, after all, you figured out a solution on your own. Conversely, it seems somewhat pointless (and maybe arrogant), to write explicitly that you reached the given conclusion and only then found the other article.
What to do in such circumstances?