Hi,

At Wed, 27 Nov 2002 07:59:47 +0900,
Gavin Sinclair wrote:
> > > What's wrong about '? :' ?
> > >
> > > irb(main):001:0> b = nil
> > > nil
> > > irb(main):002:0> (__f=b)?__f.meth : nil
> >
> > Or:
> >
> >   b.meth if b
> >
> > (if I'm understanding this part of the discussion correctly...)
> 
> Your code is equivalent to batsman's, but the OP wanted a default value thrown
> in, so:
> 
>   b and b.meth or default_value

They are not equivalent when b.meth returns nil/false.

What about this? :)

  module Kernel; def not?; self; end; end
  class FalseClass; def not?; yield; end; end
  class NilClass; def not?; yield; end; end
  catch(:property) {
    object.property.not?{throw :property, default_value}.method
  }

-- 
Nobu Nakada