F# multiple when guards using grouping patterns in pattern matching -
Why does this code work, and how does it work?
id1 = = 0 with match P1, P2. | Fluid, particle id 2, when id = id2 | Interface _, particle id 2 when id = id2 - & gt; DoSomething () ...
So what are the different ways when there are guards in pattern groups?
When you can protect per arrow / result, something like this will happen:
id 1 = 0 with match P1, P2. Fluid, particle id 2 | Interface _, particle id 2 when id = 1 id 2 - & gt; DoSomething () | _ - & gt; DoSomething ()
(In this case, the note should bind the same set of both items or identifiers, so that no identities can be left in both the positions)
or optional Add another action / result as follows:
with match P1, P2. Fluid, particle id 2 when id = 1 = id 2 - & gt; DoSomething () | Interface _, particle id 2 when id = 1 id 2 - & gt; DoSomething () | _ - & gt; DoSomething ()
Comments
Post a Comment