In a previous post i mentioned my attempt to create an environment that behaves alternately like a footnote, an endnote or a comment (i.e. hidden). Thanks to the help of those who answered the above mentioned question, i am now able to define a new environment that behaves like the footnote environment by employing one of the following two technique:
\documentclass{article}
\usepackage{environ}
\NewEnviron{mynote}{\footnote{\BODY}}
\begin{document}
Hello\begin{mynote}world\end{mynote}
\end{document}
or equivalently
\documentclass{article}
\newenvironment{mynote}{\footnote\bgroup}{\egroup}
\begin{document}
Hello\begin{mynote}world\end{mynote}.
\end{document}
Unfortunately, what works for footnotes fails for endnotes and comments. The following two blocks of code (the first for endnotes using the second technique and the second for comments using the first technique), don't even compile.
\documentclass{article}
\usepackage{endnotes}
\newenvironment{mynote}{\endnote\bgroup}{\egroup}
\begin{document}
Hello\begin{mynote}world\end{mynote}.
\theendnotes
\end{document}
\documentclass{article}
\usepackage{comment}
\usepackage{environ}
\NewEnviron{mynote}{\begin{comment}\BODY\end{comment}}
\begin{document}
Hello\begin{mynote}world\end{mynote}
\end{document}
Why do the techniques that work for footnotes fail for endnotes and comments? What can i do about it?

\footnote\bgrouptrick seems to work, but it's just by chance and the result is not really correct. I don't see the reason for using an environment. – egreg Nov 09 '13 at 11:59\NewEnviron{mynote}{}for the “comment” case. You're not compelled to use\BODY. – egreg Nov 09 '13 at 13:58