Skip to content

Instantly share code, notes, and snippets.

@mysteriouspants
Created June 6, 2011 18:44
Show Gist options
  • Save mysteriouspants/1010804 to your computer and use it in GitHub Desktop.
Save mysteriouspants/1010804 to your computer and use it in GitHub Desktop.
Yaya Functional Programming!
# originally an IRB session on [email protected]
func= lambda {|hash,key| hash[key]=Hash.new(&func)}
# => #<Proc:0x000001010621b8@(irb):1 (lambda)>
h=Hash.new &func
# => {}
h[:foo]
# => {}
h[:foo][:bar][:baaz] = 'yay functional programming!'
# => "yay functional programming!"
h.keys
# => [:foo]
h[:foo][:bar]
# => {:baaz=>"yay functional programming!"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment