From: "Carlos J. Hernandez" Date: 2008-01-04T09:57:05+09:00 Subject: Re: Finding if an array contains a data type Several ways to test, but probably I'd like best x=["a","b",2, "c"] puts "This array contains numbers" if x.find{|t| t.kind_of?(Numeric)} The method find is given to class Array by Enumerable, not so obvious. Not knowing find nor kind_of?, I'd probably do x=["a","b",2, "c"] x.each { |t| if t.to_s =~ /^\d+(\.\d+)?$/ then puts "This array contains numbers" break end } But that's just ugly. On Fri, 4 Jan 2008 09:27:05 +0900, "Sam Phoneix" said: > Say I wanted to see if an array contained a number or not. Would I use > the match method? > > E.g. > > x=["a","b",2, "c"] > > puts("This array contains numbers") if x.match(/\d/) > > > > > > I'm a real beginner at ruby, so simple explanations for simple folk > please. I appreciate your help. > -- > Posted via http://www.ruby-forum.com/. >