Ruby 4.0 introduces Array#rfind, a new method that finds the last element matching a condition by iterating backwards. Unlike reverse.find or reverse_each.find, rfind doesn't create intermediate reversed arrays or enumerators, making it more memory-efficient for large arrays. The method is specific to Array rather than Enumerable because generic enumerables can only traverse forward via #each. The same update also added an optimized Array-specific implementation of #find for better performance.
Sort: