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.
54a8d73b7712fa00c05e197ca680ad7a?d=identicon&s=25 Elpee Zit (elpee)
on 2008-11-11 02: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>
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2008-11-11 03:01
(Received via mailing list)
From: Elpee Zit [mailto:elpeeo@yahoo.com]
#...

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...
54a8d73b7712fa00c05e197ca680ad7a?d=identicon&s=25 Elpee Zit (elpee)
on 2008-11-11 03:32
Thank You !!!!
This topic is locked and can not be replied to.