有没有更干净的方法来处理F#中的双可空类型?

有没有更干净的方法来处理F#中的双可空类型?,f#,F#,我有以下两行: if not start.IsNone && not stop.IsNone then let times = TimeArray start.Value stop.Value interval 有没有更干净的方法?如果是一个值,我可以使用match,但是两个值呢?(这里是第三天…)您仍然可以使用模式匹配。考虑这个没有意义的例子,它可以帮助你理解整体模式。 let start = Some 1 let stop = Some 2 let res

我有以下两行:

if not start.IsNone && not stop.IsNone then
    let times = TimeArray start.Value stop.Value interval

有没有更干净的方法?如果是一个值,我可以使用match,但是两个值呢?(这里是第三天…)

您仍然可以使用模式匹配。考虑这个没有意义的例子,它可以帮助你理解整体模式。
let start = Some 1
let stop = Some 2    
let res =
    match start, stop with
    | Some _a, Some _b -> (_a,_b)
    | _, _ -> (0, 0)