How can I select the longest string from a Ruby array? September 8, 2023 by Tarik Just do as below using Enumerable#max_by : ar = ['one','two','three','four','five'] ar.max_by(&:length) # => "three"