F# Optional Record Field

Posted by akaphenom on Stack Overflow See other posts from Stack Overflow or by akaphenom
Published on 2010-04-14T00:53:05Z Indexed on 2010/04/14 1:03 UTC
Read the original article Hit count: 542

Filed under:
|
|

I have a F# record type and want one of the fields to be optional:

type legComponents = {
    shares : int<share> ;
    price : float<dollar / share> ;
    totalInvestment : float<dollar> ;
}

type tradeLeg = {
    id : int ;
    tradeId : int ;
    legActivity : LegActivityType ;
    actedOn : DateTime ;
    estimates : legComponents ;
    ?actuals : legComponents ; 
}

in the tradeLeg type I owuld like the the actuals field to be optional. I cant seem to figure it out nor can I seem to find a reliable example on the web. It seem like this sohuld be easy like

let ?t : int = None

but i realy can't seem to get this to work. Ugh - thank you

T

© Stack Overflow or respective owner

Related posts about F#

Related posts about optional