This project is archived and is in readonly mode.
Add Enumerable#uniq?
Reported by Bounga | March 16th, 2011 @ 11:17 AM
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.
Comments and changes to this ticket
-
Bounga March 16th, 2011 @ 11:28 AM
Github fork / branch is available at https://github.com/Bounga/rails/commits/enumerable_uniq
-
Ryan Orr March 19th, 2011 @ 06:19 PM
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>