Answers for "find even numbers in array rails"

0

how to find even number in an array ruby

my_array = [1, 2, 3, 4, 5, 6]
my_array.select{ |number| number.even?}
#OR
my_array.select{ |number| number % 2 == 0}
#OR 
my_array.find_all{ |number| number.even?}
Posted by: Guest on July-13-2020

Code answers related to "find even numbers in array rails"

Browse Popular Code Answers by Language