F
Frank Schmitt
Hi!
I just stumbled over a (at least for me) surprising behaviour
of the comma (',') operator:
irb(main):001:0> a,b = 1,2
[1, 2]
irb(main):002:0> puts a.class, b.class
Fixnum
Fixnum
nil
Ok, no surprises so far. Here we go:
irb(main):003:0> a=1, b=2
[1, 2]
irb(main):004:0> puts a.class, b.class
Array
Fixnum
nil
that is, a=1, b=2 creates an *Array* a instead of a Fixnum.
I don't think this is a bug, since others surely have spotted
this before me, but what's the rationale behind this?
kind regards
frank
I just stumbled over a (at least for me) surprising behaviour
of the comma (',') operator:
irb(main):001:0> a,b = 1,2
[1, 2]
irb(main):002:0> puts a.class, b.class
Fixnum
Fixnum
nil
Ok, no surprises so far. Here we go:
irb(main):003:0> a=1, b=2
[1, 2]
irb(main):004:0> puts a.class, b.class
Array
Fixnum
nil
that is, a=1, b=2 creates an *Array* a instead of a Fixnum.
I don't think this is a bug, since others surely have spotted
this before me, but what's the rationale behind this?
kind regards
frank