From: Todd Benson Date: 2008-08-17T12:32:47+09:00 Subject: Re: writing if statement in one line with elsif condition On Sat, Aug 16, 2008 at 10:09 PM, Luiz Vitor Martinez Cardoso wrote: > I'm trying to convert it: > > <% if @recipes.length == (i+1) %> > <% @id = 0 %> > <% elsif i.remainder(2) == 1 %> > <% @id = 1 %> > <% else %> > <% @id = 2 %> > <% end %> > > To something like: > > <% if @recipes.length == (i+1) then @id = 0 ; elsif > i.remainder(2) == 1 then @id = 1 ; else @id = 2 end >% > > But in my tests the elsif condition is totally ignored, why? Not sure, but... if 1==1 then 'a' elsif 'a'=='a' then 'b' else 'c' end => "a" if 1==2 then 'a' elsif 'a'=='b' then 'b' else 'c' end => "c" With a cursory glance, I can only guess that your first condition is always true. Maybe somebody could pipe in about ERB if that's a factor, because I'm not familiar with it. Todd