Christophe Grandsire wrote: > Selon Robert Klemme <bob.news / gmx.net>: > >>> >>> 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. > > Of course it is the only reasonable approach. I agree completely with > it. But it doesn't change that the order in which the case and the > when parts read kind of imply a left-to-right, rather than > right-to-left, relationship, especially since in other languages I > know with a case/switch expression it's exactly what happen under the > hood :) . Just out of curiosity: which languages are you referring to and what do they do? > So although I see why it *should* be the way it is in Ruby, I still > can't remember it reliably. It's not a Ruby problem, it's a me > problem ;) . > > You can for example do >> this, which might make it clearer... >> >> def Condition(&b) >> class <<b >> alias === [] >> end >> b >> end >> > > Wow! Some of the things one can do with Ruby make my head spin! The > worst is: I can understand what it means!!! ;) Pity you... :-)) >> case a_number >> when Condition {|x| x < 10} >> ... >> end >> > > Cool trick indeed :) . But I'll just try to remember the order from > now on, or at least remember how to get back to it... Ok, print this out in a bold 64pt font "I must never forget that in a CASE statement conditions have their === invoked." :-) Kind regards robert