Wednesday, 2 October 2013

Multiple Variable Assignment from Single Hash Ruby

Multiple Variable Assignment from Single Hash Ruby

Hello All This seems like a day 1 question, And I feel like I've had it
working before, but for some reason I'm at a loss. But I'm trying to have
an Array assign a value to two variables.
test = "hello, my,name,is,dog,how,are,you"
testsplit = test.split ","
testsplit.each do |x,y|
puts y
end
I would think that it would print my is how you
but it appears the values only get passed to x and not to y. When i run
this code y comes back as empty.

No comments:

Post a Comment