-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Description
How to interpret the following?
(match [1 2]
[x] 1
[x y] 2)With Janet 1.38.0, it evaluates to 1, instead of 2.
It looks like a list pattern only needs to match the prefix of the target value. The documentation is a bit vague:
an array or bracket tuple will match only if all of its elements match the corresponding elements in
x.
Is this a bug or a feature? I think prefix matching can be better expressed as [x & _]. (Side note: currently this will make a slice for the rest elements and bind it to _, probably not needed.)
ifreund
Metadata
Metadata
Assignees
Labels
No labels