ReasonML unit — what does unit mean?
In a strongly typed language you need to define what a function returns every time, but sometimes a function does not return something. This is what unit is used for, unit is used to defining when a function does not return anything.
let log = () => {
print_endline("hello");
print_endline("world")
}; log();
Functions always need argument and with reason when you call the function “()” evaluates to “unit” and since the last line in a function is automatically returned the function has also a return type of unit, because print_endline returns “unit”.
So unit can be a bit confusing at the start coming from JavaScript which is a weakly typed language, but once you begin to use it more and understand the basic principals like there always needs type even when nothing is given.