From: John Joyce Date: 2007-04-12T03:26:14+09:00 Subject: Re: Proc&Bloc Try your code again in irb. then, in irb times3.class Should give you the answer. Proc When you def gen_times, actually, you are telling how to create an instance of Proc with a code block. gen_times's code block happens to take the factor and multiply it by n this is like a function object. If you've only been at it one week, don't worry. It will become clear! On Apr 12, 2007, at 2:43 AM, Yaya __ wrote: > Hi > I start learning ruby since a week but i have some probleme to > undestand > Proc > and the philosophy which hides behind . > Why don't using methode ? > In this code vhere is the Proc? > > def gen_times(factor) > return Proc.new {|n| n*factor } > end > > times3 = gen_times(3) > times5 = gen_times(5) > > times3.call(12) #=> 36 > times5.call(5) #=> 25 > times3.call(times5.call(4)) #=> 60 > > Really it do not arrive to undertand > > -- > Posted via http://www.ruby-forum.com/. >