Ruby - Enumerable and Collection Processing
Identify the error in this Ruby code that tries to find the first negative number:
numbers = [3, 5, -2, 7] result = numbers.find do |n| n < 0 end puts result
Identify the error in this Ruby code that tries to find the first negative number:
numbers = [3, 5, -2, 7] result = numbers.find do |n| n < 0 end puts result
do...end block with variable n is valid syntax for find.find accepts a block and returns the first element matching n < 0.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions