On 8/4/07, Bas van Gils <bas / 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.