Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
RobertKerans
5y ago
0 comments
Save
Share
It is pattern matching, the semantics are an OCaml/ML family `match` expression.
0 comments
3 comments · 1 top-level
top
newest
oldest
moonchild
5y ago
· 2 in thread
Ah, so it is[0]. The GP's example doesn't require pattern matching though; as I mentioned, it would work in a language lacking it.
0.
https://haxe.org/manual/lf-pattern-matching-structure.html
yawaramin
5y ago
How so?
moonchild
5y ago
[playerA.move, playerB.move] is an array literal value, as are [Rock, Scissors] and the other controlling expressions. The switch simply performs a direct comparison between the two; there need be no destructuring for that to work.
1 more reply
j
/
k
navigate · click thread line to collapse