-
Clamp for min/max values
Using clamp To Restrict Values to a Certain Range — Add this to my “I didn’t notice Ruby added this” pile. The clamp method was introduced in Ruby 2.4 and lets you do things like this: 500.clamp(1, 100) # => 100
Using clamp To Restrict Values to a Certain Range — Add this to my “I didn’t notice Ruby added this” pile. The clamp method was introduced in Ruby 2.4 and lets you do things like this: 500.clamp(1, 100) # => 100