Created
June 6, 2011 18:44
-
-
Save mysteriouspants/1010804 to your computer and use it in GitHub Desktop.
Yaya Functional Programming!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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