Find the Last Matching Element with rfind

Ruby 4.0 landed during Christmas 2025 with a bunch of new features. One small but useful addition is Array#rfind , which finds the last element in an array that matches a condition. Instead of… …reversing the array or using reverse_each to find from the end: numbers = [ 2 , 2 , 3 , 4 , 6 , 7 , 8 ] numbers . reverse . find ( & :odd? ) #=> 7 # or numbers . reverse_each . find ( & :even? ) #=> 8 Use……