On 8/5/07, evanwebb / gmail.com <evanwebb / gmail.com> wrote: > 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. Full ack, though if you look through some of the mess we have seen in this thread, this looks good by comparison. The issue is that the OP is building a DSL for non-english speakers and needs to have an if construct that matches the language. So the send_if bit is part of the implementation details for that. That having been said, the only benefit of the above is that it lends nicely to dynamic buildup of calls, but I'd prefer passing around lambdas, all else considered equal. It just seems like the OP wants to avoid blocks in general.