Skip to content

Instantly share code, notes, and snippets.

@teeparham
Created December 3, 2015 17:38
Show Gist options
  • Save teeparham/7f162dbc2bb0ea2f3f2e to your computer and use it in GitHub Desktop.
Save teeparham/7f162dbc2bb0ea2f3f2e to your computer and use it in GitHub Desktop.
Functional Ruby
# define a closure x that exposes function y
x = -> {
y = -> { puts "y" };
{ y: y }
}
# invoke public function y on x
x.()[:y].()
# alternately
x.call[:y].call
# => not pretty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment