Skip to content

Instantly share code, notes, and snippets.

@hkoba
Last active January 3, 2016 02:09
Show Gist options
  • Save hkoba/8393373 to your computer and use it in GitHub Desktop.
Save hkoba/8393373 to your computer and use it in GitHub Desktop.
Perl's '//' operator in OCaml, but this is type-safe.
let (//) optional default =
match optional with
| None -> default
| Some x -> x
(* You can use this like:
(Map.find t s // 0) + 1
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment