From: "David A. Black" Date: 2010-05-07T20:23:45+09:00 Subject: Re: Include? on array of objects Hi -- On Fri, 7 May 2010, Greg Ma wrote: >> ar = ["a", "b" , "cd"] >> puts "found 'a'" if ar.include?('a') >> puts "found single char!" if ar.detect{|el| el.size == 1} > > > Ok thanks I have to use Detect Other fun variations on the theme: ar.find {|el| el.size == 1 } # synonym for detect ar.any? {|el| el.size == 1 } # returns true/false, so kind of # a hybrid of include? and find David -- David A. Black, Senior Developer, Cyrus Innovation Inc. THE Ruby training with Black/Brown/McAnally COMPLEAT Coming to Chicago area, June 18-19, 2010! RUBYIST http://www.compleatrubyist.com