For me looks good. I have tested it on my MX Linux
distribution.
It’s interesting how much the code says about it’s author. In my case 7 years in Elixir
gives result …
-
Even if somehow I remember somewhat about
try/catch
I was still looking for a “better” solution, so I have added one extra dependency for a singleisdigit
call. -
std:err
of course! When I saw your code I have reminded it immediately. -
stdexcept
is interesting. Maybe I have used it, but I don’t remember it much especiallye.what()
call. I guess that I haven’t used multiple catch blocks before inC++
. -
out_of_range
error handling is simple, but also brilliant idea. I’m not surprised that I wasn’t thinking about such edge case since inElixir
we have justInteger
for all well … integers (no small or big ones). -
I only wonder why you define
num
variable outside oftry
block having in mind it’s only usage is within it, but that’s definitely not the most important thing.
So much to learn in such a small code, thanks!
Adding additional links below to the documentation pages: