Let say I have a function that return the lesser of two input values of type int
. I want to set the precondition to only allow a and b of type int
.
class Example
functions
min: int * int -> int
min(a, b) ==
if a < b
then a
else b
-- The code below doesn't work
-- pre varName1 = int
end Example
When I omit the precondition and enter print Example.min(12.345, 0.123)
in the interpreter, I got 0.123 in return.
How do I ensure that the function will only accept inputs of type int
?