Skip to content

Instantly share code, notes, and snippets.

View spanuska's full-sized avatar

Skylar Paul spanuska

View GitHub Profile
@cflee
cflee / ruby-blocks-procs-lambdas.md
Created January 14, 2015 07:10
Discoveries about Ruby Blocks, Procs and Lambdas

Ruby: Blocks, Procs, Lambdas

Note that for blocks, {} and do ... end are interchangeable. For brevity, only the former will be listed here.

Version differences

Pre-1.9, lambda and proc are synonyms. Essentially the difference is between proc and block.

def method(&block) p block.class; p block.inspect; end
l = lambda { 5 }