On Aug 5, 4:47 pm, "Gregory Brown" <gregory.t.br... / gmail.com> wrote:
> On 8/4/07, Bas van Gils <b... / van-gils.org> wrote:
>
>
>
> > On Thu, Aug 02, 2007 at 04:48:30AM +0900, dohzya wrote:
>
> > > Do you want something like this  :
> > > ---
> > > def sendif( args, &bloc )
> > >   if args[:if]
> > >     send args[:then].shift, *args[:then], &bloc
> > >   else
> > >     send args[:else].shift, *args[:else], &bloc if args[:else]
> > >   end
> > > end
>
> > > sendif :if => 1 < 2, :then => [:p, "gagne"], :else => [:puts, "perdu"]
> > > ---
> > > ?
>
> > Damn, that's elegant!
>
> I dig it too, though I like better:
>
> sendif 1 < 2, :then => [:p, "gagne"],  :else => [:puts, "perdue"]
>
> just because it kills the redundant if.

To put in my 2 cents, this offends my senses. Whats wrong with:

if 1 < 2
 p "gagme"
else
 puts "perdue"
end

or even
1 < 2 ? p "gagme" : puts "perdue"

Calling a method with a hash argument just to perform a condition
makes me cringe, performance wise. Plus it just seems so overly
clever.