if → case

This commit is contained in:
Gwenhael Le Moine 2021-12-15 13:31:32 +01:00
parent 9a08ce176f
commit 413f98c964
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

11
repl.rb
View file

@ -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