From: Felipe Giotto Date: 2008-01-31T21:06:52+09:00 Subject: Re: can ik make this more beautifull? Actually, when you set x to nil, in the end of the code, you're losing your entire second "if" clause. Unless these conditions are calls to other functions or something like that, you could refactor your code this way: x = condition1 ? 1 : nil Best regards! Felipe Giotto ;-) On Jan 31, 2008 9:52 AM, Remco Hh wrote: > nowadays i try to improve my coding style to produce nicer and beter > readable code. I try to improve the following code but i dont know how. > > if condtion1 > x=1 > else > if condition2 > x=2 > else > if condition3 > x=3 > end > end > x=nill > end > > there are three different conditions which can not occur at the same > time > can i make this nicer? > -- > Posted via http://www.ruby-forum.com/. > > -- Felipe Luiz Christófolli Giotto Inovare Development Team http://www.inovare.net