F# using match to validate parameters
问题 I'm learning F#. I want to know best practices for validating input parameters. In my naivety I had thought I could do something like this: let foo = match bar with | <test for valid> -> bar | _ -> "invalid" of course that doesn't work due to mismatching types. So I'd like to see the patterns experienced F# programmers use for this sort of thing. match? If/then/else? Something else? 回答1: You are having problems because you are trying to bind a value to something that could be two possible