> > You can do
> >
> > case
> >     when object.method == 'whatever' then ...
> >     when ohject.id%2 == 0 then ...
> > end
...
> This sounds like a use case for the Proc.new extension proposal in the
> latest ruby-dev summary...
...
> So your code could be:
>   crit1 = Proc.new(:===){|x| x.method === 'whatever'}
>   case object
>     when crit1
>   end
...
> Hmmm... I didn't like the idea before, but I might be changing my mind.

Let's factor out the variable, so we get

  case object
  when Proc.new(:===){|x| x.method == 'whatever' }
    ... do stuff1
  when Proc.new(:===){|x| x.id%2 == 0 }
    ... do stuff2
  end

Now, how about I write instead:

  if object.method == 'whatever'
    ... do stuff1
  elsif object.id%2 == 0
    ... do stuff2
  end

Well, I know which one I'd prefer to read or write :-)

If the underlying objective is just to factor out the common 'object.' in
each branch, then I'd still suggest

  object.instance_eval {
    case
    when method == 'whatever'
      ... do stuff1
    when id%2 == 0
      .. do stuff2
    end
  }

Regards,

Brian.