From: Brian Candler Date: 2012-09-05T15:24:55+09:00 Subject: Re: Best coding for limiting a value ? Regis d'Aubarede wrote in post #1074698: > B) > result=value > if value < min then result= min end > if value > max then result= max end You can avoid the temporary variable by using the return value from 'if' and 'case' expressions. case when value < min min when value > max max else value end This scrunches to: case when value < min: min; when value > max: max; else value; end (I have a vague idea that something changed about using colon in if/case - but I've tested this with 1.8.7 and it works) There's also the modifier form of if: result = value result = min if value < min result = max if value > max -- Posted via http://www.ruby-forum.com/.