From: Bertram Scharpf Date: 2007-07-31T07:46:21+09:00 Subject: Re: array.include? Hi, Am Dienstag, 31. Jul 2007, 07:22:48 +0900 schrieb Tim Hunter: > >On Jul 30, 11:17 am, Jeffrey Bowen wrote: > > > >>if @status_array.include? @status_number > >>else > >> @status_array << @status_number > >>end > >> > > > If it was me, I'd just use a hash instead of an array, with > @status_number as the key and anything (1, for example) as the value. > Let the hash object figure out if @status_number is already a key. It'll > be fast, and any time you need a list of status_numbers, just call > hash.keys. Probably it is useful to count them. @status_hash = Hash.new 0 ... @status_hash[ status_number] += 1 Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de