From: Ari Brown Date: 2007-08-26T01:46:32+09:00 Subject: Re: How can I make this if/else more succinct? 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 ~ Ari English is like a pseudo-random number generator - there are a bajillion rules to it, but nobody cares.