I have a record type
type Record = { Start: DateTime; End: DateTime; Duration: TimeSpan }
let record = { Start = DateTime.Now; End = DateTime(2021,12,1) }
This code won't compile as there's no assignment given for field Duration.
Is it possible to calculate Duration in the type definition instead of assigning it?
Solved it:
type Record = { Start: DateTime; End: DateTime; }
with
member this.Duration = this.End - this.Start
let record = { Start = DateTime.Now; End = DateTime(2021,12,1) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With