Quantcast
Viewing all articles
Browse latest Browse all 38

Answer by Tarmil for Why Does F# Pattern Matching for a String Type Match a ReadOnlySpan?

When you use an identifier in a pattern, you're not testing equality with an existing value (or type). Instead, you're defining a pattern that always matches, and giving the matched value the given name in the scope following the pattern.

To test for equality, you need to use a when guard instead:

    match parameterTypes with    | [| (arg1, ParameterAttributes.None); (arg2, ParameterAttributes.Out) |]        when arg1 = typeof<string> && arg2 = typeof<uint64>.MakeByRefType()        -> Some m    | _ -> None

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>