- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.1k
Closed
Labels
dotnet-fsharp/svchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]
Milestone
Description
Documentation lacks examples of
val mutable fields and way of their mutation without implicit copying of structure.
[<Struct>]
type Foo = 
  val mutable bar: string
  member self.ChangeBar bar = self.bar <- bar
  new (bar) = {bar = bar}
let foo = Foo "1"
foo.ChangeBar "2" //make implicit copy of Foo, changes the copy, discards the copy, foo remains unchanged
printfn "%s" foo.bar //prints 1
let mutable foo' = Foo "1"
foo'.ChangeBar "2" //changes foo'
printfn "%s" foo'.bar //prints 2Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 9a067d5a-bb13-9991-c808-c7c49a00ca47
- Version Independent ID: 201272a0-3350-93f3-8965-4a745671c7e7
- Content: Structures (F#)
- Content Source: docs/fsharp/language-reference/structures.md
- Product: dotnet-fsharp
- GitHub Login: @cartermp
- Microsoft Alias: phcart
Neftedollar
Metadata
Metadata
Assignees
Labels
dotnet-fsharp/svchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]