We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6cc2a57 commit 312d84aCopy full SHA for 312d84a
data/tutorials/language/0it_01_basic_datatypes.md
@@ -705,6 +705,14 @@ val ghorghor_bey : character =
705
- : int = 17
706
```
707
708
+To construct a new record with some field values changed without typing in the unchanged fields we can use record update syntax as shown:
709
+```ocaml
710
+# let togrev = { ghorghor_bey with name = "Togrev"; level = 20; armor_class = -6 };;
711
+val togrev : character =
712
+ {name = "Togrev"; level = 20; race = "half-ogre"; class_type = Fighter;
713
+ alignment = (Chaotic, R_Neutral); armor_class = -6}
714
+```
715
+
716
Note that records behave like single constructor variants. That allows pattern matching on them.
717
```ocaml
718
# match ghorghor_bey with { level; _ } -> level;;
0 commit comments