ruby if blocks

For all of ruby's block-orientedness, the if operator doesnt take a block. if true   puts "hello there" end

with a patch you can use receiver.if

true.if { puts "hello there" }

the patch is

class Object   def if     yield   end end  class FalseClass   def if   end end class NilClass   def if   end end

(from 'chris2' in freenode/#ruby-lang)

tags: