Last active
February 11, 2020 22:40
-
-
Save ohlawdie/13bb45ca714a05c0b16f1a71568a825a to your computer and use it in GitHub Desktop.
ExplicitField VAL #F F# #Let
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Line 4 and 17 | |
| type MyType() = | |
| let mutable myInt1 = 10 | |
| [<DefaultValue>] val mutable myInt2 : int | |
| [<DefaultValue>] val mutable myString : string | |
| member this.SetValsAndPrint( i: int, str: string) = | |
| myInt1 <- i | |
| this.myInt2 <- i + 1 | |
| this.myString <- str | |
| printfn "%d %d %s" myInt1 (this.myInt2) (this.myString) | |
| let myObject = new MyType() | |
| myObject.SetValsAndPrint(11, "abc") | |
| // The following line is not allowed because let bindings are private. | |
| // myObject.myInt1 <- 20 | |
| myObject.myInt2 <- 30 | |
| myObject.myString <- "def" | |
| printfn "%d %s" (myObject.myInt2) (myObject.myString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment