From 413f98c96406300ef85f20b88062ee776a48c3ff Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 15 Dec 2021 13:31:32 +0100 Subject: [PATCH] =?UTF-8?q?if=20=E2=86=92=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repl.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/repl.rb b/repl.rb index 0434120..ac5dea0 100644 --- a/repl.rb +++ b/repl.rb @@ -37,21 +37,24 @@ class RplRepl end def format_element( elt ) - if elt[:type] == :numeric && elt[:base] != 10 + case elt[:type] + when :numeric prefix = case elt[:base] when 2 '0b' when 8 '0o' + when 10 + '' when 16 '0x' else "0#{elt[:base]}_" end - return "#{prefix}#{elt[:value].to_s( elt[:base] )}" + "#{prefix}#{elt[:value].to_s( elt[:base] )}" + else + elt[:value] end - - elt[:value] end def print_stack