From eeb513929b55d97d52329f9d9618d5eda19bc778 Mon Sep 17 00:00:00 2001 From: Piyush Ranjan <11230167+piyuple@users.noreply.github.com> Date: Sat, 23 Nov 2024 14:39:44 +0530 Subject: [PATCH] Correct OCaml record field assignment syntax Fixed an error in the OCaml article where record field assignments incorrectly used `:` instead of `=`. Updated example: ```ocaml let cow = { name = "cow"; color = "brown"; legs = 4 };; --- ocaml.html.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ocaml.html.markdown b/ocaml.html.markdown index 2c5e13d5..69d934a8 100644 --- a/ocaml.html.markdown +++ b/ocaml.html.markdown @@ -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 @@ -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 *)