Skip to content

Collection Instanciation Error : OCaml #5003

Open
@lokasku

Description

@lokasku

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"
*)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions