Replies: 5 comments 1 reply
-
Different syntactical precedence. Try inserting |
Beta Was this translation helpful? Give feedback.
-
Also, if left hand side is a type test, |
Beta Was this translation helpful? Give feedback.
-
@Happypig375 Punctuation let testP3(x) =
match (x) with
| ([a] | [a;_]) & c ->
Console.WriteLine(Literal.stringify c)
let testK3(x) =
match (x) with
| [a] | [a;_] as c ->
Console.WriteLine(Literal.stringify c)
|
Beta Was this translation helpful? Give feedback.
-
Also, if left hand side is a type test, |
Beta Was this translation helpful? Give feedback.
-
Good question! Here's my way of understanding these constructs:
Note that you can mix and match:
Using the "catch-all" variable, you can get the same with For ANDHere's where
Should note that a more sensible use of
ORHere you can see that you can capture just as well to a variable using Note that the last
|
Beta Was this translation helpful? Give feedback.
-
I found that
as
and&
were very similar in pattern matching, so I did the test.run it:
Unsurprisingly, the outputs are the same for both.
With
&
can implement the function, why define an additionalas
? Which is the official recommended way of writing?Beta Was this translation helpful? Give feedback.
All reactions