Longest item in array
- by c00lryguy
Is there an easier way than below to find the longest item in an array?
arr = [
[0,1,2],
[0,1,2,3],
[0,1,2,3,4],
[0,1,2,3]
]
longest_row = []
@rows.each { |row| longest_row = row if row.length > longest_row.length }
p longest_row # => [0,1,2,3,4]