Reputation: 503
@a = 200
@b = 1
@c = @a / @b
@c
is going to equal 200. How can I institute a max value for @c
to be 100?
if @c = 99, do nothing
if @c = 100, do nothing
if @c > 100, make @c 100
In SQL, this is the LEAST
function.
Upvotes: 2
Views: 943
Reputation: 9146
case @c
when 99
## do something
when 100
## do something
else
@c = 100 if @c > 100
# or
@c = [@c, 100].min # inspired by minitech answer
end
Upvotes: -1