From: David Chelimsky Date: 2008-01-04T10:00:19+09:00 Subject: Re: Finding if an array contains a data type On Jan 3, 2008 6:58 PM, David Chelimsky wrote: > On Jan 3, 2008 6:52 PM, Tim Hunter wrote: > > So, here's how to use it: > > > > irb(main):001:0> x=["a","b",2, "c"] > > => ["a", "b", 2, "c"] > > irb(main):002:0> x.any? {|p| p.is_a? Numeric} > > => true > > Sam - I'd go with Tim's suggestion (.any?) rather than what I proposed (.find). > > .find returns the first object in the Array, whereas .any? returns > boolean, which seems to be a better fit (semantically) for what you're > after. Although I wonder what your opinion (Tim) is on is_a? vs ===. > > Cheers, > David >