From: Jano Svitok Date: 2008-10-24T21:06:32+09:00 Subject: Re: Bound macro in ruby On Fri, Oct 24, 2008 at 13:19, Me Me wrote: > thanks for answering: > > in my case it's something I can easy implement with if-clause, but I > wanted to know if this could be done in one single line def bound(min, value, max) (value > max) ? max : ((value < min) ? min : value end I propose replacing > with >=, because in case when value==max it will be evaluated faster def bound(min, value, max) (value >= max) ? max : ((value < min) ? min : value end