[ruby/irb] Use max_by for longest_cmd_name_length

(https://github.com/ruby/irb/pull/628)

https://github.com/ruby/irb/commit/5e87f3bfdd

Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
This commit is contained in:
Andy Waite 2023-07-04 16:45:02 -04:00 committed by git
parent 6b2abe570f
commit fd6da40fef

View File

@ -14,7 +14,7 @@ module IRB
def execute(*args)
commands_info = IRB::ExtendCommandBundle.all_commands_info
commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
output = StringIO.new