Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lessismore1/d458a78807ceba20dd8a46b746527485 to your computer and use it in GitHub Desktop.
Save lessismore1/d458a78807ceba20dd8a46b746527485 to your computer and use it in GitHub Desktop.
F# Records - Default Values
// 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