function together with a referencing environment - a table storing a reference to each of the non-local variables (also called free variables) of that function. A closure - unlike a plain function pointer - allows a function to access those non-local variables even when invoked outside of its immediate lexical scope. Tuesday, May 14, 13
is a pretty cool language!" end #=> python is a pretty cool language! # ruby is a pretty cool language! # lua is a pretty cool language! Tuesday, May 14, 13
end args(Proc.new{|a, b, c| puts "Give me a #{a} and a #{b} and a #{c.class}"}) args(lambda{|a, b, c| puts "Give me a #{a} and a #{b} and a #{c.class}"}) # => Give me a 1 and a 2 and a NilClass # *.rb:8: ArgumentError: wrong number of arguments (2 for 3) (ArgumentError) Tuesday, May 14, 13