Hi -- On Sun, 26 Aug 2007, Ari Brown wrote: > > On Aug 24, 2007, at 10:45 PM, eggie5 wrote: > >> Actually how can this be more succinct? >> >> Video.find(:all).each do |video| >> if video._3gp ==1 >> ext=".3gp" >> elsif video._3g2==1 >> ext=".3g2" >> elsif video.mp4==1 >> ext=".mp4" >> end >> expected.push "#{self.id}_#{video.id}#{ext}" >> end > > You can use case-when: > > Video.find(:all).each do |video| > case 1 > when video._3gp : ext = ".3gp" > when video._3gp2 : ext = ".3gp2" > when video.mp4 : ext = ".mp4" > end > expected.push "#{self.id}_#{video.id}#{ext}" > end Just to streamline it a bit, you could also do: Video.find(:all).each do |video| ext = case 1 when video._3gp: ".3gp" when video._3gp2: ".3gp2" when video.mp4: ".mp4" end expected.push "#{self.id}_#{video.id}#{ext}" end Of course you could also do: Video.find(:all).each do |video| expected.push "#{self.id}_#{video.id}#{case 1; when .... } " end but that crosses over into cleverness and/or cutesiness :-) David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)