examples
examples copied to clipboard
Example Suggestion: Safe Arithmetic
Just going through the examples, thank you so much for the effort you are making here.
I am reading through the Arithmetic example and I think there's the obvious edge case about dividing by zero.
According to roc's current div documentation:
Division by zero is undefined in mathematics. As such, you should make sure never to pass zero as the denomaintor to this function! Calling div on a Dec denominator of zero will cause a panic.
Possible solutions:
-
Adjust the example text to state that if the second argument is
0
, we can skip theinteger quotient
operation; -
Adjust the example text to state that zero is not a valid input for the second argument, and add an explicit check on the
readArgs
function for this case -
Adjust the example text to state that an input of 0 on the second argument is allowed to crash with a
Floating point exception
My preference would be between solution 1 or 2, or a smarter one :)
Let me know your thoughts and once again, thank you for this amazing effort!