From fd6da40fef5c6b818564ed0bc47672d1e069039c Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:45:02 -0400 Subject: [PATCH] [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 --- lib/irb/cmd/show_cmds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/cmd/show_cmds.rb index acced27d48..490561825e 100644 --- a/lib/irb/cmd/show_cmds.rb +++ b/lib/irb/cmd/show_cmds.rb @@ -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