Ruby - Write program to get the largest number in an array

Requirements

Write program to get the largest number in an array

Hint

Use each method on array

Demo

my_array = %w{10 56 92 3 49 588 18} 
highest_number = 0 #  w ww. j a v a 2 s.  c  o m
my_array.each do |number| 
  number = number.to_i 
  highest_number = number if number > highest_number 
end 
puts highest_number

Result

Related Exercise