Y
Yaya __
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
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