Hi there.
I'm coming to ruby mainly from python background.
in python
a = b = range(10)
will yields two names pointing to the same object
but in ruby
a = b = Range.new(0,9)
will yield two two distinct objects.
To get the effect of the python line in ruby it seems I have to do:
b = Range.new(0,9)
a = b
What's the logic behind that?
···
--
Alex Polite
http://flosspick.org - finding the right open source
See this session:
irb(main):001:0> a = b = Range.new(0, 9)
=> 0..9
irb(main):002:0> a.object_id
=> 1744024
irb(main):003:0> b.object_id
=> 1744024
-- fxn
···
On Jan 28, 2006, at 14:47, Alex Polite wrote:
Hi there.
I'm coming to ruby mainly from python background.
in python
a = b = range(10)
will yields two names pointing to the same object
but in ruby
a = b = Range.new(0,9)
will yield two two distinct objects.
Alex Polite wrote:
in python
a = b = range(10)
will yields two names pointing to the same object
but in ruby
a = b = Range.new(0,9)
will yield two two distinct objects.
Actually, it won't.
How did you come to this conclusion?
···
--
http://flgr.0x42.net/
Did just that. Should have done it twice I guess 
alex
···
On 1/28/06, Xavier Noria <fxn@hashref.com> wrote:
See this session:
irb(main):001:0> a = b = Range.new(0, 9)
=> 0..9
irb(main):002:0> a.object_id
=> 1744024
irb(main):003:0> b.object_id
=> 1744024
--
Alex Polite
http://flosspick.org - finding the right open source