Skip to content

uniq! returns nil when it is after a shifting operation. #1434

@juneng603

Description

@juneng603

Hi, all.

There is a problem to use uniq! for an array with shifting operations.
It seems to be a bug.

options = [1, 1, 1]
options.shift
p options.uniq
p options.uniq! { |h| h }

The expected result is

[1]
[1]

But, the returned values are

[1]
nil

It should return "[1]" for the second.

The testing environments are
ruby :

$ ruby --version
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]

jruby :

$ ruby --version
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]

and the referenced document is from
http://www.ruby-doc.org/core-2.1.0/Array.html#method-i-uniq

Returns nil if no changes are made (that is, no duplicates are found).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions