Create record instance with default values
F# allows adding methods/properties to records and discriminated unions:
type Person =
{
Name: string
Age: int
}
with
static member Default = { Name = ""; Age = 0 }
In FSI:
> Person.Default;;
val it : Person = {Name = "";
Age = 0;}
Used unchecked.DefaultOf<'t>
. However be aware that F# records are immutable, so this is probably not what you want.