yield/splat problem in 1.8.6

S

steve

[Note: parts of this message were removed to make it a legal post.]

Hey guys,

I just came across this weird behavior in 1.8. It works in 1.9 so I'm
assuming it's a bug. Is this a known issue?

def yield_array
yield [1, 2]
end

def yield__yield_array
yield_array {|a| yield(a) }
end

def yield__yield_array__with_splat
yield_array {|*a| yield(*a) }
end

yield__yield_array {|args| p args }
yield__yield_array__with_splat {|args| p args }
# both as expected:
# => [1, 2]

yield__yield_array {|(a,b)| p a, b }
# as expected:
# => 1, 2
yield__yield_array__with_splat {|(a,b)| p a, b }
# NOT AS EXPECTED !!?!?!
# => [1, 2], nil

- steve
http://coderrr.wordpress.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top