Below is a code snippet which gives me some headache:
def headache
yield(*(foo(1)),“bar”)
end
def foo(n)
[n,n+2,n+5]
end
headache { |a,b,c,d| puts a.to_s; puts b.to_s; puts c.to_s; puts d }
I had expected that this would print
Below is a code snippet which gives me some headache:
def headache
yield(*(foo(1)),“bar”)
end
def foo(n)
[n,n+2,n+5]
end
headache { |a,b,c,d| puts a.to_s; puts b.to_s; puts c.to_s; puts d }
I had expected that this would print
Hi,
In message “Re: Syntax error with array interpolation”
on Mon, 25 Jun 2007 23:35:11 +0900, “Ronald F.”
[email protected] writes:
|Below is a code snippet which gives me some headache:
1.8 allows argument splat (*) only at the end of argument list.
Wait for 1.9.
matz.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs