Skip to content

Commit 1fe1a44

Browse files
shethaaditAdit Sheth
andauthored
Resolved bug 44181 for namespaces. (#44275)
Co-authored-by: Adit Sheth <[email protected]>
1 parent fc620f3 commit 1fe1a44

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/fsharp/language-reference/namespaces.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,34 @@ type PeelState = Peeled | Unpeeled
8282
// This exception depends on the type below.
8383
exception DontSqueezeTheBananaException of Banana
8484
85-
type Banana(orientation : Orientation) =
85+
type Banana(orientation: Orientation) =
8686
member val IsPeeled = false with get, set
8787
member val Orientation = orientation with get, set
88-
member val Sides: PeelState list = [ Unpeeled; Unpeeled; Unpeeled; Unpeeled] with get, set
88+
member val Sides: PeelState list = [Unpeeled; Unpeeled; Unpeeled; Unpeeled] with get, set
8989
9090
member self.Peel() = BananaHelpers.peel self // Note the dependency on the BananaHelpers module.
9191
member self.SqueezeJuiceOut() = raise (DontSqueezeTheBananaException self) // This member depends on the exception above.
9292
9393
module BananaHelpers =
94-
let peel (b: Banana) =
94+
let peel (banana: Banana) =
9595
let flip (banana: Banana) =
9696
match banana.Orientation with
9797
| Up ->
9898
banana.Orientation <- Down
9999
banana
100100
| Down -> banana
101101
102+
// Update the peel state for all sides of the banana.
102103
let peelSides (banana: Banana) =
103104
banana.Sides
104105
|> List.map (function
105106
| Unpeeled -> Peeled
106107
| Peeled -> Peeled)
107108
108-
match b.Orientation with
109-
| Up -> b |> flip |> peelSides
110-
| Down -> b |> peelSides
109+
// Apply the flipping and peeling logic based on the orientation.
110+
match banana.Orientation with
111+
| Up -> banana |> flip |> peelSides
112+
| Down -> banana |> peelSides
111113
```
112114

113115
Note that the exception `DontSqueezeTheBananaException` and the class `Banana` both refer to each other. Additionally, the module `BananaHelpers` and the class `Banana` also refer to each other. This wouldn't be possible to express in F# if you removed the `rec` keyword from the `MutualReferences` namespace.

0 commit comments

Comments
 (0)