-
-
Save chad/1490380 to your computer and use it in GitHub Desktop.
Revisions
-
Chad Fowler revised this gist
Dec 17, 2011 . 1 changed file with 3 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,12 @@ def add(key, value, dictionary = Proc.new{}) lambda do |x| key == x ? value : dictionary.call(x) end end d = add("a",5) d = add("b",6, d) p d.call("b") p d.call("a") p d.call("c") -
latompa created this gist
Dec 17, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ def dictionary lambda {|x| nil } end def add(key, value, dictionary) lambda do |x| key == x ? value : dictionary.call(x) end end d = dictionary d = add("a",5, d) d = add("b",6, d) p d.call("b") p d.call("a") p d.call("c")