From: Nadeesha Meththananda Date: 2007-11-15T19:34:52+09:00 Subject: Re: Array checking ???????????????????? Axel Etzold wrote: > -------- Original-Nachricht -------- >> Datum: Thu, 15 Nov 2007 18:59:07 +0900 >> Von: Nadeesha Meththananda >> An: ruby-talk@ruby-lang.org >> Betreff: Array checking ???????????????????? > >> eg: >> >> (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 THANKS A LOT PAL -- Posted via http://www.ruby-forum.com/.