Sometimes a longstanding answer has so many upvotes that it stays at the top even if it's no longer the best answer. In cases like that, there's usually a comment that explains why that method is no longer preferred and what you should do instead -- sometimes pointing to the better answer. And if no such comment exists, be kind and add it.