Forum: Ruby Help me understand this

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Elpee Z. (Guest)
on 2008-11-11 03:43
I have my own theory, but I haven't seen the implementation yet. Or
maybe it's something simple, and I am just making things complicated.
Here goes:


-> irb
irb(main):001:0> b,c = 1,2
=> [1, 2]
irb(main):002:0> a = b,c = 1,2
=> [1, 1, 2]
irb(main):003:0> a
=> [1, 1, 2]
irb(main):004:0> a.inspect
=> "[1, 1, 2]"
irb(main):005:0> a.class
=> Array
irb(main):006:0>
Peña, Botp (Guest)
on 2008-11-11 04:01
(Received via mailing list)
From: Elpee Zit [mailto:removed_email_address@domain.invalid]
#...

this,

> b,c = 1,2
=> [1, 2]
> b
=> 1
> c
=> 2

compare to this,

> b,c = [1,2]
=> [1, 2]
> b
=> 1
> c
=> 2

then,

> a = b,c = 1,2
=> [1, 1, 2]
> a
=> [1, 1, 2]
> b
=> 1
> c
=> 1

compare

> a = [b,(c = 1),2]
=> [1, 1, 2]
> a
=> [1, 1, 2]
> b
=> 1
> c
=> 1

it's an array all to the right...
Elpee Z. (Guest)
on 2008-11-11 04:32
Thank You !!!!
This topic is locked and can not be replied to.