Skip to content

Instantly share code, notes, and snippets.

@dsomel21
Created June 4, 2016 19:00
Show Gist options
  • Save dsomel21/ac9ab55c1e77490f5e25a2829b10ee76 to your computer and use it in GitHub Desktop.
Save dsomel21/ac9ab55c1e77490f5e25a2829b10ee76 to your computer and use it in GitHub Desktop.
Return the highest value of an array
def maximum(arr)
highest = arr[0]
arr.each {|num| return highest = num if num>highest}
return highest
end
puts maximum([19, 69, 21, 55])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment