From: "Jan E." Date: 2012-04-12T17:48:41+09:00 Subject: Re: conditionally use greater than or less than Hi, You can use the generalized comparision operator <=>, which returns -1, 0 or 1 depending on the order of the operands. If you set the result for the operation, you can force it to either do ">" comparisons or "<" comparisons: comparison_result = condition ? 1 : -1 # comparisons: if condition is true, then a <=> b == comparison_result means # a > b, otherwise it means a < b 1 <=> 3 == comparison_result 4 <=> 2 == comparison_result However, the "send" solution is probably easier to understand: compare = condition ? :> : :< 1.send compare, 3 4.send compare, 2 -- Posted via http://www.ruby-forum.com/.