I want to assign an empty array to multiple variables. Here is what I'm doing:
irb(main):015:0> a, b, c = []
=> []
irb(main):016:0> a
=> nil
irb(main):017:0> b
=> nil
irb(main):018:0> c
=> nil
It gives me nil
. I wonder why? But if I did this:
irb(main):019:0> a, b, c = [], [], []
=> [[], [], []]
irb(main):020:0> a
=> []
irb(main):021:0> b
=> []
irb(main):022:0> c
=> []
then it works as I expect, but it's a little bit longer than the first one. What's wrong with the first example?