Created
March 8, 2013 21:28
-
-
Save mauropm/5120023 to your computer and use it in GitHub Desktop.
Nice example about lambda usage in ruby #metaprogramming
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
def n_times(n) | |
#codigo | |
lambda {|val| n * val} | |
end | |
two_times = n_times(2) | |
puts two_times.call(3) | |