it is the name of the result returned by your code. () : unit is a trivial placeholder value returned from things that are side-effect based.
It's more obvious when you enter something that's more commonly an expression at the prompt, e.g...
- 2 * 7;
val it = 14 : int
2
votes
You can also use it for the side effect of printing things out:
fun printpos n =
if n <= 0 then (print "not positive!\n")
else (print (Int.toString n); print "\n");
printpos ~1;
printpos 1;
(* Output:
val printpos = fn : int -> unit
not positive!
val it = () : unit
1
val it = () : unit
*)
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more