Pattern match guard with DateTime.TryParseExact?
问题 How to guard with DateTime.TryParseExact (and get the parsed value if possible)? The following code doesn't work. [<EntryPoint>] let main args = let argList = args |> List.ofSeq match argList with | "aaa" :: [] -> aaa.main "aaa" | "bbb" :: [] -> bbb.main "bbb" | "ccc" :: yyyymm :: [] when DateTime.TryParseExact (yyyymm, "yyyyMM", CultureInfo.InvariantCulture, DateTimeStyles.None)-> ccc.main "ccc" yyyymm 回答1: You can use a mutable : let mutable dt = Unchecked.defaultof<_> match argList with |