"Ralf M?ller" <r_mueller / imp-ag.de> schrieb im Newsbeitrag
news:2s1qktF1cjkj8U1 / uni-berlin.de...
> Salve!
>
> Is it possible in the 'when'-part to access components or mthods of an
> object specified in after 'case' ?
>
> Something like:
>
> case object
>     when object.method == 'whatever' then ...
>     when ohject.id%2 == 0 then ...
> end

You can do

case
    when object.method == 'whatever' then ...
    when ohject.id%2 == 0 then ...
end

Note the subtle difference. :-)

Alternatively you can define a criterion like this:

crit1 = lambda {|x| x.method == 'whatever'}
class <<crit1; alias :=== :call end

case object
  when crit1; ...
  when crit2; ...
end

Kind regards

    robert