Multi-variable Initialization Gotcha
Sometimes the fact that I don't know all the ins and outs of Ruby, coupled with habits carried over from other languages, turns around to bite me. Here's a console session demonstration of the latest problem I had:
[sourcecode language='ruby']
>> a = b = 2
=> 2
>> a = 3
=> 3
>> b
=> 2
>> a = b = []
=> []
>> a << 2
=> [2]
>> b
=> [2]
>> a = []; b = []
=> []
>> a << 2
=> [2]
>> b
=> []
[/sourcecode]
So, trying to initialize multiple arrays and multiple integers doesn't work the same. Live and learn.
[sourcecode language='ruby']
>> a = b = 2
=> 2
>> a = 3
=> 3
>> b
=> 2
>> a = b = []
=> []
>> a << 2
=> [2]
>> b
=> [2]
>> a = []; b = []
=> []
>> a << 2
=> [2]
>> b
=> []
[/sourcecode]
So, trying to initialize multiple arrays and multiple integers doesn't work the same. Live and learn.