Forum: Ruby on Rails checking for an object in a collection

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
70461a4707c93b3bd7f7a750f1191444?d=identicon&s=25 Pieter Mans (feanix)
on 2006-12-31 13:15
Is there a quick way to to check for an object's existence in a
collection?
317aad7f9f0b69a440faca74bbe22b20?d=identicon&s=25 Jakob Skjerning (Guest)
on 2006-12-31 13:32
(Received via mailing list)
Pieter Mans wrote:
>
> Is there a quick way to to check for an object's existence in a
> collection?

collection.include?(object) or collection.find(object) depending on what
collection you have, I guess.

--
Jakob Skjerning - http://mentalized.net
70461a4707c93b3bd7f7a750f1191444?d=identicon&s=25 Pieter Mans (feanix)
on 2006-12-31 15:34
Jakob Skjerning wrote:
> Pieter Mans wrote:
>>
>> Is there a quick way to to check for an object's existence in a
>> collection?
>
> collection.include?(object) or collection.find(object) depending on what
> collection you have, I guess.
>
> --
> Jakob Skjerning - http://mentalized.net

Thanks!
72f8ab180f81f9c544e2b58da399c0be?d=identicon&s=25 Elad Meidar (eizesus)
on 2006-12-31 20:01
(Received via mailing list)
correction, find on a collection works only for id.
This topic is locked and can not be replied to.