Given a float, say (2.0), I want to convert it to an Integer type. It looks like Integer.parse only works for strings as far as I can tell.
Integer.parse(2.0)
(FunctionClauseError) no function clause matching in Integer.count_digits/2
Use trunc(2.0)
or round(2.0)
. Those are auto-imported since they are part of Kernel and they are also allowed in guard clauses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With