Function definition and semi-column

Hello,

I don’t understand the second part of this sequence :

# let test () = ();;
val test : unit -> unit = <fun>
# test ();;
- : unit = ()
# let test () = ()
  test;;
Lines 1-2, characters 14-4:
1 | ..............()
2 | test..
Error: The constructor () expects 0 argument(s),
       but is applied here to 1 argument(s)

I need to use the second part of the sequence because I am writing my code in a file. So I don’t use the ;; to separate my statements. I don’t get how to separate them so that I first have the definition of test, then the call of the function without any argument (or even with an () argument it does not work).

Newlines are not significant in OCaml. Your second phrase reads as

let test () = () test

when you meant

let test () = ();;
test ()

or

let test () = ()
let () = test ()
1 Like

Thank you octachron. It make sense know.