From: Robert Klemme Date: 2005-10-26T17:12:03+09:00 Subject: Re: Comparing Classes with Case ? Christophe Grandsire wrote: > En r�ponse � Jacob Fugal : >> >> On the right track, but it's actually the right argument. That is: >> >> irb(main):001:0> String === "string" >> => true >> > > You're right of course! I keep forgetting that order :( . > >> That's because the left hand side is the receiver (=== is just >> another method). When the receiver is a Class, Class#=== is called. >> >> irb(main):002:0> String.===( "string" ) >> => true >> > > It makes sense, but I still have difficulties remembering it :( . > >> >> A when clause for a case statement evaluates using === with the when >> argument as the receiver and case argument as argument. So: >> > > Yes, and although the order makes sense, from a functional point of > view, it is difficult to get my head around the idea that case > indicates the argument rather than the receiver. If you think about it for a moment you'll see that it's the only reasonable approach: the expression after the case is the item to test and all expressions after when denomiate conditions. You can for example do this, which might make it clearer... def Condition(&b) class <