The name #uniq? here is not a good representation of the method's
functionality here. You're checking for uniqueness of a single member
of the collection, but in use the context would be the entire
collection. @people.uniq? being true should mean @people itself is, in
some way, unique. You'd need to come up with a better way of saying
@people.has_only_one_of?; it may be tough to come up with an
intuitive, succinct name for that, and using something long doesn't
make too much sense when @people.select{}.size==1 is already pretty
accessible.




On Mar 16, 7:42 am, Nicolas Cavigneaux <[email protected]> wrote:
> Hello !
>
> I wrote an ActiveSupport patch to add a new feature.
>
> This is a tiny tested patch that checks for Enumerable content uniqueness.
>
> It returns true if the collection has no duplicated content and 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 and doc are included.
>
> Please test this useful tiny patch.
>
> https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6...
>
> Github fork / branch is available 
> athttps://github.com/Bounga/rails/commits/enumerable_uniq
>
> Have a nice day.
> --
> Nicolas Cavigneauxhttp://www.bounga.orghttp://www.cavigneaux.net

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to