John Lam 1997 — 2026

Obscure metadata trivia

Is this a bug?

``` public enum HideEm { ToString, Equals } ```

Well, the C# compiler doesn’t think so, and it doesn’t even issue a warning.

But what’s really going on here is that you’re defining static fields called Equals and ToString, which of course mask the definitions of the corresponding methods in Object.

Now, if you’re a statically typed language you don’t even care since the compiler can infer whether you’re referencing a field vs. calling a method. But in Ruby, how do you distinguish between these things?

1 archived reader comment

Justin (2006/07/20)

Just make sure you can get to the Reflection namespace using RubyCLR and you can forget obscure corner cases like this one.