Skip to content

Commit 702a3f5

Browse files
authored
Merge pull request #531 from Szer/patch-1
Create snipper6704.fs
2 parents 16d1027 + fc98626 commit 702a3f5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```fsharp
2+
[<Struct>]
3+
type Foo =
4+
val mutable bar: string
5+
member self.ChangeBar bar = self.bar <- bar
6+
new (bar) = {bar = bar}
7+
8+
let foo = Foo "1"
9+
foo.ChangeBar "2" //make implicit copy of Foo, changes the copy, discards the copy, foo remains unchanged
10+
printfn "%s" foo.bar //prints 1
11+
12+
let mutable foo' = Foo "1"
13+
foo'.ChangeBar "2" //changes foo'
14+
printfn "%s" foo'.bar //prints 2
15+
```

0 commit comments

Comments
 (0)