Robert Klemme wrote:
> "Ralf Mler" <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
> 
thanks robert,
this lambda mechanism is an interessting point.
What you do, is an in-place-extension of 'class' only for its actual 
instance 'object', right? And you call it '===', because 'case' needs 
this functcion.
But whitch alias do you choose for 'crit2?

ralf

--------------------------------------------------------------------
Ceterum censeo cartaginem esse dilendam.