Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Created May 16, 2015 12:45
Show Gist options
  • Save KamilLelonek/80daccb842ea45110794 to your computer and use it in GitHub Desktop.
Save KamilLelonek/80daccb842ea45110794 to your computer and use it in GitHub Desktop.
Closures example in Ruby
[1] (pry) main: 0> outer = 1
=> 1
[2] (pry) main: 0> increment = -> value { outer + value }
=> #<Proc:0x007fb94c87e148@(pry):2 (lambda)>
[3] (pry) main: 0> increment[2]
=> 3
[4] (pry) main: 0> increment::(2)
=> 3
[5] (pry) main: 0> increment.(2)
=> 3
[6] (pry) main: 0> increment.call(2)
=> 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment