2008年5月1日 星期四

lambda and proc

lambda:
parameter:  block
return: an instance of class Proc

Proc:
procedure
method:  
call:
tell proc to do sth

ex:
test = lambda { |i| i + 1 }
test.call(2)
--> 3

the method to pass parameters
1. test.call(2) 
2.  test[2]

another method to create Proc:
Proc.new {   }

沒有留言: