Ruby/Array/max by

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

max_by with block

langs = %w[java perl python ruby]    # Which has the longest name?
langs.max_by {|word| word.length }   # => "python": Ruby 1.9 only