From: Axel Etzold Date: 2007-11-15T19:07:48+09:00 Subject: Re: Array checking ???????????????????? -------- Original-Nachricht -------- > Datum: Thu, 15 Nov 2007 18:59:07 +0900 > Von: Nadeesha Meththananda > An: ruby-talk@ruby-lang.org > Betreff: Array checking ???????????????????? > > > hi > > i have written a array like this. > > my_array = ["one","two","three","four"] > > no i want to check a given string is can be found from the above array. > > eg: > > if ( my_array.map{"one"} ) > return true; > else > return false; > end > > > so here if i use "five" insted of "one" it should return false( as i > think) but it does no happen. > > (simply want to check a given string is in the array or not) > > so if any body can help???? > -- > Posted via http://www.ruby-forum.com/. Dear Nadeesha, you can use class Array def contains_entry?(entry) if self-[entry]==self return false else return true end end end a=["one","two",3,4] p a.contains_entry?("three") The idea is to see whether the array stays the same when you take away something from it - if yes, that something wasn't in the array in the first place. Best regards, Axel -- Psssst! Schon vom neuen GMX MultiMessenger geh�rt? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger