Skip to content

Instantly share code, notes, and snippets.

@tlehman
Created October 22, 2014 22:07
Show Gist options
  • Select an option

  • Save tlehman/6c55032412417ac5c330 to your computer and use it in GitHub Desktop.

Select an option

Save tlehman/6c55032412417ac5c330 to your computer and use it in GitHub Desktop.
procs vs lambdas (making ruby blocks into objects using proc or lambda)
a = proc { return 1 }
# ==> #<Proc:0x007f96d280a118@(irb):1>
b = lambda { return 1 }
# ==> #<Proc:0x007f96d3002438@(irb):3 (lambda)>
a.call
# =LocalJumpError: unexpected return
# = from (irb):1:in `block in irb_binding'
# = from (irb):5:in `call'
# = from (irb):5
# = from /usr/bin/irb:12:in `<main>'
b.call
# ==> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment