Skip to content

Commit

Permalink
Use idiomatic Case instead of If for char formatter
Browse files Browse the repository at this point in the history
Co-authored-by: Sijawusz Pur Rahnama <[email protected]>
  • Loading branch information
nanobowers and Sija authored Nov 1, 2024
1 parent ffce41d commit 30c9569
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/string/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ struct String::Formatter(A)
end

def char(flags, arg) : Nil
val = if arg.is_a?(Char)
val = case arg
when Char
arg
elsif arg.is_a?(Int::Primitive)
when Int::Primitive
arg.chr
else
raise ArgumentError.new("Expected a char or integer, not #{arg.inspect}")
Expand Down

0 comments on commit 30c9569

Please sign in to comment.