Skip to content

Commit 297dc01

Browse files
authored
Update mutually recursive record definition example (#27648)
It's incomplete without this change :)
1 parent 458cec0 commit 297dc01

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/fsharp/language-reference/records.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Records in F#
33
titleSuffix: ""
44
description: Learn how F# records represent simple aggregates of named values, optionally with members.
5-
ms.date: 08/15/2020
5+
ms.date: 12/21/2021
66
---
77
# Records (F#)
88

@@ -107,6 +107,24 @@ and Address =
107107
Occupant: Person }
108108
```
109109

110+
To create instances of both, you do the following:
111+
112+
```fsharp
113+
// Create a Person type and use the Address type that is not defined
114+
let rec person =
115+
{
116+
Name = "Person name"
117+
Age = 12
118+
Address =
119+
{
120+
Line1 = "line 1"
121+
Line2 = "line 2"
122+
PostCode = "abc123"
123+
Occupant = person
124+
}
125+
}
126+
```
127+
110128
If you were to define the previous example without the `and` keyword, then it would not compile. The `and` keyword is required for mutually recursive definitions.
111129

112130
## Pattern Matching with Records

0 commit comments

Comments
 (0)