Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
@a = 200 @b = 1 @c = @a / @b
@c将等于 200。如何设置最大值为@c100?
@c
if @c = 99, do nothing if @c = 100, do nothing if @c > 100, make @c 100
在 SQL 中,这是LEAST函数。
LEAST
Enumerable#min作品:
Enumerable#min
[@c, 100].min
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