Undefined values: Difference between revisions

added ocaml
(added ocaml)
Line 53:
delete obj.c;
obj.c == null;</lang>
 
=={{omit fromheader|OCaml}}==
 
<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}}
506

edits