Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add Enumerable#uniq?

#6588

Checks for Enumerable content uniqueness

Returns true if the collection has no duplicated content.
Can be called with a block too, much like any?, so people.uniq? { |p| p.age > 26 } returns true if only 1 person is over 26.

Unit test are included.

Please test and +1 this useful tiny patch.

Reported by Bounga · March 16th, 2011 @ 11:17 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Bounga
  2. Bounga
  3. Bounga
  4. Ryan Orr
    Ryan Orr

    Took a look at the code in the last patch that you posted. I like the implementation but you were missing a test that checked a block that produced a result that wasn't unique. I added a test for this and cleaned up some whitespace errors that I was getting with your patch.

    To avoid whitespacing errors in the future try the command:

    git diff --check

    This will tell you which files are producing whitespace errors if any.

    March 19th, 2011 @ 06:19 PM