Skip to content

Instantly share code, notes, and snippets.

@masterT
Last active April 26, 2016 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masterT/fc4a35ddbd412ab5f594b716afe74c70 to your computer and use it in GitHub Desktop.
Save masterT/fc4a35ddbd412ab5f594b716afe74c70 to your computer and use it in GitHub Desktop.
Ocaml Examples
let f ?(x = Some("valeur par default")) () =
match x with
| Some (y) -> print_string y
| None -> print_string "None"
;;
(* val f : ?x:string option -> unit -> unit = <fun> *)
f ();;
(* valeur par default- : unit = () *)
f ~x:None ();;
(* None- : unit = () *)
f ~x:(Some "ma valeur") ();;
(* ma valeur- : unit = () *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment