[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strange ruby-1.9.1 array substitution answer

Michel Demazure

5/28/2009 6:06:00 PM

Strange !

arr = [1,2,3,4,5]
arr[0,2] = nil
=> ruby 1.8 : arr = [3,4,5]
=> ruby 1.9 : arr = [nil, 3,4,5]

ruby -v
ruby 1.9.1 (2008-10-28 revision 19983) [i386-mswin32]
--
Posted via http://www.ruby-....

4 Answers

Roger Pack

5/28/2009 6:29:00 PM

0

Michel Demazure wrote:
> Strange !
>
> arr = [1,2,3,4,5]
> arr[0,2] = nil
> => ruby 1.8 : arr = [3,4,5]
> => ruby 1.9 : arr = [nil, 3,4,5]

that might be a bugI'd ask the core people.
-=r
--
Posted via http://www.ruby-....

Antonio Cangiano

5/28/2009 6:31:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Thu, May 28, 2009 at 2:06 PM, Michel Demazure <michel@demazure.com>wrote:

> Strange !
>
> arr = [1,2,3,4,5]
> arr[0,2] = nil
> => ruby 1.8 : arr = [3,4,5]
> => ruby 1.9 : arr = [nil, 3,4,5]
>
> ruby -v
> ruby 1.9.1 (2008-10-28 revision 19983) [i386-mswin32]


It's a bug. They either fixed it in a more recent version or it's a Windows
specific issue. On my Mac it works as expected:

$ ruby1.9 -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9]

$ irb
>> arr = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
>> arr[0,2] = nil
=> nil
>> arr
=> [3, 4, 5]

Cheers,
Antonio
--
My startup: http://Th...
Zen and the Art of Programming: http://AntonioCa...
Aperiodico di resistenza informatica: http://Sta...
Author of "Ruby on Rails for Microsoft Developers": http://bit.l...

Roger Pack

5/28/2009 6:44:00 PM

0


> It's a bug. They either fixed it in a more recent version or it's a
> Windows
> specific issue. On my Mac it works as expected:
>
> $ ruby1.9 -v
> ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9]
>
> $ irb
>>> arr = [1,2,3,4,5]
> => [1, 2, 3, 4, 5]
>>> arr[0,2] = nil
> => nil
>>> arr
> => [3, 4, 5]


Here's what I get in Linux with TRUNK.
>> RUBY_DESCRIPTION
=> "ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux]"
>> arr = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
>> arr[0,2] = nil
=> nil
>> arr
=> [nil, 3, 4, 5]

maybe macs are special? "Guess we're not cool enough" (from commercial).
Just kidding.
Take care.
-=r
--
Posted via http://www.ruby-....

Michel Demazure

5/28/2009 7:00:00 PM

0

Roger Pack wrote:
>
>> It's a bug. They either fixed it in a more recent version or it's a
>> Windows
>> specific issue. On my Mac it works as expected:

> Here's what I get in Linux with TRUNK.

> maybe macs are special? "Guess we're not cool enough" (from commercial).
> Just kidding.
> Take care.
> -=r

Open source ... and many open ends
M.
--
Posted via http://www.ruby-....