learnxinyminutes-docs
learnxinyminutes-docs copied to clipboard
Collection Instanciation Error : OCaml
I noticed an error in the Records/A collection of values with named fields
chapter when instantiating cow
variable:
type animal =
{
name: string;
color: string;
legs: int;
}
;;
let cow =
{ name: "cow";
color: "black and white";
legs: 4;
}
;;
val cow : animal
cow.name ;;
- : string = "cow"
This should be replaced by
type animal =
{
name: string;
color: string;
legs: int;
}
;;
let cow =
{ name = "cow";
color = "black and white";
legs = 4;
}
;;
(*
val cow : animal
cow.name ;;
- : string = "cow"
*)