P
Pedro Del Gallego
Hi, im new to ruby. I ve qaquestions about closures
1) if i defiene this
def loopN n, &b
i=0
while (i<n) do
b.call
i+=1
end
end
Why the first and the second calls dosnt works and the third works?
1.1) loopN 5, {puts "hola"} # compile error , parse error unexpected
"{", expected "$"
1.2) loopN 5 {puts "hola"} # compile error , unexpected tString.
1.2) loopN (5) {puts "hola"} # works
thanks
1) if i defiene this
def loopN n, &b
i=0
while (i<n) do
b.call
i+=1
end
end
Why the first and the second calls dosnt works and the third works?
1.1) loopN 5, {puts "hola"} # compile error , parse error unexpected
"{", expected "$"
1.2) loopN 5 {puts "hola"} # compile error , unexpected tString.
1.2) loopN (5) {puts "hola"} # works
thanks