I am following this OCaml tutorial.
They provided the two functions below and said that they are equivalent.
let string_of_int x = match x with
| 0 -> "zero"
| 1 -> "one"
| 2 -> "two"
| _ -> "many"
let string_of_int2 = function
| 0 -> "zero"
| 1 -> "one"
| 2 -> "two"
| _ -> "many"
My query is regarding the syntax of the above functions.
I wrote the same function but instead of
| 0 ->I simply did0 ->and the function still works in the same way. Is there any particular reason that the tutorial added the extra|in their function?In the second function what is the use of the
functionkeyword and why was this keyword absent in the first function?