From: Siep Korteling Date: 2010-05-07T18:58:44+09:00 Subject: Re: Include? on array of objects Greg Ma wrote: > Hi, > Is it possible to use include? on an array of objects? I would like to > find a particular property of my object. > Unless so, how would you do so? > > Greg You can use Array#include?(arg) but it will return true only if arg is an element of the array. For finding a particular property use #detect. ar = ["a", "b" , "cd"] puts "found 'a'" if ar.include?('a') puts "found single char!" if ar.detect{|el| el.size == 1} hth, Siep -- Posted via http://www.ruby-forum.com/.