From: Dave Thomas Date: 2000-07-04T15:27:18-05:00 Subject: [ruby-talk:03807] Re: Immature idea for case-when Aleksi Niemel� writes: > > Well, you can do something (almost) equivalent in standard Ruby--you > > can associate closures with the 'when' conditions: > .. > > when check {|n| n & 1 == 0} > > puts "#{number} is even" > .. > > Quite neat hack, thanks Dave! This probably solves few problems, but I could > argue that my original case remains intact (or one have to duplicate some > code). I agree it is different to the inverse case. I just thought it was fun to see what could be done within the current language. > case obj:method # look, I just invented notation :) > when arg # leading to obj.method(arg) > > This has one notable feature: > > case obj:=== > when arg But the current method uses arg.===(obj), whereas extrapolating from above this would be obj.===(arg) Perhaps the way to attach this is not by extending case at all, but by simply defining a new selector control structure using methods in the existing language. Regards Dave