Just a gentle reminder that this,

def twice(greeting)
  greeting.call
  greeting.call
end

twice lambda{ puts 'Hello' }

this,

def twice
  yield
  yield
end

twice { puts 'Hello' }

and this

def twice(&blk)
  blk.call
  blk.call
end

twice { puts 'Hello' }

all do the same thing

Inspired by Avdi Grimm’s Ruby Tapas

blog comments powered by Disqus