[#11439] comments needed for Random class — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

15 messages 2007/06/12

[#11450] Re: new method dispatch rule (matz' proposal) — David Flanagan <david@...>

This is a late response to the very long thread that started back in

17 messages 2007/06/13

[#11482] Ruby Changes Its Mind About Non-Word Characters — James Edward Gray II <james@...>

Does this look like a bug to anyone else?

10 messages 2007/06/16

[#11505] Question about the patchlevel release cycle — Sylvain Joyeux <sylvain.joyeux@...4x.org>

1.8.6 thread support was broken in bad ways. It stayed for three months

20 messages 2007/06/20
[#11512] Re: Question about the patchlevel release cycle — Urabe Shyouhei <shyouhei@...> 2007/06/20

Hi, I'm the 1.8.6 branch manager.

[#11543] Re: Apple reportedly to ship with ruby 1.8.6-p36 unless informed what to patch — James Edward Gray II <james@...>

On Jun 27, 2007, at 4:47 PM, Bill Kelly wrote:

10 messages 2007/06/27

Array#slice!() expands array inconsistently

From: Florian Gross <florgro@...>
Date: 2007-06-15 14:02:30 UTC
List: ruby-core #11469
Hi,

I just stumbled upon this behaviour while specifying Array methods for
Rubinius:

irb(main):001:0> ary = [1, 2]
=> [1, 2]
irb(main):002:0> ary.slice!(100)
=> nil
irb(main):003:0> ary
=> [1, 2]
irb(main):004:0> ary.slice!(100, 0)
=> nil
irb(main):005:0> ary
=> [1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil]

Is this intended behaviour? I'd expect .slice!() with an index and an
index and a length to behave consistently. (I'd also expect
Array#slice!() not to increase the size of the Array.)

It also happens with a range, btw:

irb(main):001:0> ary = [1, 2]
=> [1, 2]
irb(main):002:0> ary.slice!(100...100)
=> nil
irb(main):003:0> ary
=> [1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil]

I'm seeing this in ruby 1.8.4 (2005-12-24) and ruby 1.9.0 (2007-04-02
patchlevel 0).

The documentation says that is equivalent to this Ruby code:

        def slice!(*args)
          result = self[*args]
          self[*args] = nil
          result
        end

If that were the case slice!(100) would also expand the Array.

Kind regards,
Florian Gross


In This Thread

Prev Next