On Apr 4, 2011, at 3:06 PM, Simon Harrison wrote: > Thanks for all the tips. I think #select fits best: > > file_results = @films.select { |a, b| /#{@film}/i =~ a } > > > Just one question. Obviously in the above, a and b refer to the first > and second elements in each subarray. Let's say we have this array: > > => [["one", "two", "three"], ["one"], ["two", "three"], ["one", > "three"]] > > What would be the best way to search for 'one' (or whatever) in this > case? > > Cheers > > -- > Posted via http://www.ruby-forum.com/. > irb> @films = [["one", "two", "three"], ["one"], ["two", "three"], ["one", "three"]] => [["one", "two", "three"], ["one"], ["two", "three"], ["one", "three"]] irb> @film = 'One' => "One" irb> @films.select{|film,*_| /#{@film}/i =~ film} => [["one", "two", "three"], ["one"], ["one", "three"]] _ is a valid identifier and I tend to use it to mean either "a throwaway placeholder" (like in this usage) or "a quick, single block arg" (as in arry.map{|_|_.something} to mean the same as arry.map(&:something) without needing Symbol#to_proc). -Rob Rob Biedenharn Rob / AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab / GaslightSoftware.com http://GaslightSoftware.com/