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.
Pieter M. (Guest)
on 2006-12-31 14:15
Is there a quick way to to check for an object's existence in a
collection?
Jakob S. (Guest)
on 2006-12-31 14:32
(Received via mailing list)
Pieter M. 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 S. - http://mentalized.net
Pieter M. (Guest)
on 2006-12-31 16:34
Jakob S. wrote:
> Pieter M. 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 S. - http://mentalized.net

Thanks!
Elad M. (Guest)
on 2006-12-31 21:01
(Received via mailing list)
correction, find on a collection works only for id.
This topic is locked and can not be replied to.