From: Giles Bowkett Date: 2006-10-31T07:50:10+09:00 Subject: Re: !x.include? y > > ... > > list.reject! {|thing| not list_of_acceptable_values.include? thing.attribute} > > > > is there a nicer way to do it? > > You could modify the Array class to include an accept! method that > does the opposite of reject! (I'm sure someone else will chime in if > this is wrong or bad practise!) > > class Array > def accept! > delete_if {|item| not yield item} > end > end this is a very tempting solution. a filter method could be cool too. -- Giles Bowkett http://www.gilesgoatboy.org