checking for an object in a collection

3 views
Skip to first unread message

Pieter Mans

unread,
Dec 31, 2006, 7:15:50 AM12/31/06
to rubyonra...@googlegroups.com
Is there a quick way to to check for an object's existence in a
collection?

--
Posted via http://www.ruby-forum.com/.

Jakob Skjerning

unread,
Dec 31, 2006, 7:30:31 AM12/31/06
to rubyonra...@googlegroups.com
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

Pieter Mans

unread,
Dec 31, 2006, 9:34:50 AM12/31/06
to rubyonra...@googlegroups.com

Thanks!

Elad Meidar - Creopolis.com

unread,
Dec 31, 2006, 1:54:28 PM12/31/06
to Ruby on Rails: Talk
correction, find on a collection works only for id.

Reply all
Reply to author
Forward
0 new messages