Undefined values: Difference between revisions
added ocaml
m (moved Syntactically explicit undefined to Undefined values) |
(added ocaml) |
||
Line 53:
delete obj.c;
obj.c == null;</lang>
<lang ocaml>(* There is no undefined value in OCaml, but one can emulate this with union types *)
type value = Int of int | Undefined;;
let inc = function
Int n -> Int (n+1)
| Undefined -> failwith "Undefined argument";;
inc (Int 0);;
(* - : value = Int 1 *)
inc Undefined;;
(* Exception: Failure "Undefined argument". *)</lang>
=={{header|Oz}}==
Line 256 ⟶ 271:
{{omit from|Java|everything is null or defined}}
▲{{omit from|OCaml}}
|