[LRUG] Passing Multiple Blocks in Ruby

Paul Mucur mudge at mudge.name
Mon Jul 9 15:34:20 PDT 2012


Hot on the heels of Pablo's presentation tonight ("What Ruby Can't
Do"), somewhat annealed by the Slaughtered Lamb's wares and keen to
exercise some of the thornier corners of Ruby's syntax (particularly
from 1.9 onwards), I present the following for your consideration:
"Implementing if in Ruby"
http://mudge.github.com/2012/07/09/implementing-if-in-ruby.html

I explain in detail in the post but I've whipped up a small gem called
"if" that allows you to do the following were you feeling so inclined:

  some_predicate.if ->{ "I'm true!" }, else: ->{ "I'm false!" }

The whole thing is tongue-in-cheek (using such code in production is
probably tantamount to treason) but does make me wonder how many of
Ruby's keywords could be removed.

-- mudge



More information about the Chat mailing list