Hi --

On Wed, 27 Nov 2002, Gavin Sinclair wrote:

> From: <dblack / candle.superlink.net>
>
>
> > [batsman:]
> > > 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
>
> The original and the best!

You mean you don't like:

  (b || Class.new.module_eval {
      def meth; "default value"; end; self
    }.new) .meth

??  :-)

(It's been a long week....)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav