Exploring Ruby's `clamp` and `minmax` methods
30-Sep-2021 1608
I came across an interesting problem recently where I was given a value and an array of “buckets” and I basically needed to return which bucket the value was closest to.This made me extremely excited at the prospect of having a practical use case for Ruby’s Comparable.
Exploring Ruby's `clamp` and `minmax` methods #ruby #rubydeveloper #rubyonrails #Exploring #Ruby's #`clamp` #`minmax` #methods https://rubyonrails.ba/link/exploring-ruby-s-clamp-and-minmax-methods