Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ocaml/en] Correct OCaml record field assignment syntax #5189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ocaml.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ type animal =
;;

let cow =
{ name: "cow";
color: "black and white";
legs: 4;
{ name = "cow";
color = "black and white";
legs = 4;
}
;;
val cow : animal
Expand Down Expand Up @@ -488,7 +488,7 @@ filter (fun x -> x < 4) [3; 1; 4; 1; 5] ;; (* Gives [3; 1; 1]) *)
(* However, you can create mutable polymorphic fields *)
type counter = { mutable num : int } ;;

let c = { num: 0 } ;;
let c = { num = 0 } ;;
c.num ;; (* Gives 0 *)
c.num <- 1 ;; (* <- operator can set mutable record fields *)
c.num ;; (* Gives 1 *)
Expand Down