
Issue #17097 has been updated by jnchito (Junichi Ito). `max_of` method is very elegant! I really want the Ruby version of this method. For example, I need to write `column_width = @ls_files.map { |ls_file| ls_file.name.size }.max` to determine column width according to the longest file name (in the image below, it would be 19 because "credentials.yml.enc" is the longest, and see also [this](https://github.com/JunichiIto/ruby-practices/pull/2/files#diff-50ea26a97f113...))  I'd be pretty if I could write `column_width = @ls_files.max_of { |ls_file| ls_file.name.size }` . ---------------------------------------- Feature #17097: `map_min`, `map_max` https://bugs.ruby-lang.org/issues/17097#change-100762 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal ---------------------------------------- `min`, `min_by`, `max`, `max_by` return the element that leads to the minimum or the maximum value, but I think it is as, or even more, frequent that we are interested in the minimum or the maximum value itself rather than the element. For example, to get the length of the longest string in an array, we do: ```ruby %w[aa b cccc dd].max_by(&:length).length # => 4 %w[aa b cccc dd].map(&:length).max # => 4 ``` I propose to have methods that return the minimum or the maximum value. Temporarily calling them `map_min`, `map_max`, they should work like this: ```ruby %w[aa b cccc dd].map_max(&:length) # => 4 ``` `map_min`, `map_max` are implementation-centered names, so perhaps better names should replace them, just like `yield_self` was replaced by `then`. -- https://bugs.ruby-lang.org/