I've seen some answers that suggest alternative methods to do what the OP wants—sometimes these suggestions don't fit into any of the question's tags, but they still fully do what the OP wanted.
In some cases, the alternatives can be much more closely related to the subject, and then I suppose it's appropriate. But what about in cases like above? Obviously, using another method completely can sometimes be rewarding, but is it really our business to not directly answer the question and suggest another method?
The author came for an answer to the question, and although the code does what it's supposed to, the question is not being answered.
So my question is, is it really appropriate to answer questions like that?