From: Sharon and Dave Date: 2008-06-06T21:21:11+09:00 Subject: Re: [QUIZ] Price Ranges (#164) Here's my quick attempt Cheers, Dave ----------------------------- def select_shops shops, wanted_min, wanted_max shops.select do |shop| (wanted_max ? wanted_max>= shop[:prices].min : true) && (wanted_min ? wanted_min<= shop[:prices].max : true) end end shops= [{:name=> 'Company A', :prices=> 1_000.. 3_000}, {:name=> 'Company B', :prices=> 6_000..10_000}, {:name=> 'Company C', :prices=> 500.. 2_500}] select_shops(shops, 2_500, 4_000).each do |shop| puts shop[:name] end