From: Jari Williamsson Date: 2008-01-31T21:23:07+09:00 Subject: Re: can ik make this more beautifull? 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? A case expression is probably the most clear alternative. The shortest is perhaps something like: x = condition1 ? 1 : condition2 ? 2 : 3 Best regards, Jari Williamsson