Ruby: What's going on here?

Posted by user204078 on Stack Overflow See other posts from Stack Overflow or by user204078
Published on 2010-06-17T20:44:02Z Indexed on 2010/06/17 21:13 UTC
Read the original article Hit count: 112

Filed under:

This question is based off some really odd code I recently found in a colleagues work. He claims not to know how it works only he copied it from somewhere else. That's not good enough for me I want to understand what's going on here.

Say we have something like

(test1, test2, test3="3", test4="4")

the result will be that test1 == "3", test2 == "4", test3 == nil and test4 == "4" I understand why this happens, but if we do something like

(test1, test2, test3="3", test4="4", test5 = "5", test6 = "6")

now the result is test1 == "3", test2 == "4", test3 == "5", test4 == "6", test5 == "5", test6 == "6"

Why isn't test5 == nil?

© Stack Overflow or respective owner

Related posts about ruby