From 5e87f3bfddfbe98366ebd121f5999a3838d49c03 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] Use `max_by` for `longest_cmd_name_length` (#628) 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 acced27d4..490561825 100644 --- a/lib/irb/cmd/show_cmds.rb +++ b/lib/irb/cmd/show_cmds.rb @@ -14,7 +14,7 @@ class ShowCmds < Nop 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