-
-
Save lessismore1/d458a78807ceba20dd8a46b746527485 to your computer and use it in GitHub Desktop.
F# Records - Default Values
This file contains 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
// Rather than use [<DefaultValue>], define a default record. | |
type MyRecord = { | |
field1 : int | |
field2 : int | |
} | |
let defaultRecord1 = { field1 = 0; field2 = 0 } | |
let defaultRecord2 = { field1 = 1; field2 = 25 } | |
// Use the with keyword to populate only a few chosen fields | |
// and leave the rest with default values. | |
let rr3 = { defaultRecord1 with field2 = 42 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment