3 ms·
It’s fine. Python just introduced expression assignment. Why not use that? match subject case [first := _, rest := _] return [rest, fir
by Spivak 6y ago
It’s fine. Python just introduced expression assignment. Why not use that?
match subject
case [first := _, rest := _]
return [rest, first]
- collyw 6y agoWell get to Perl eventually
- pfalcon 6y agoNote that the original PEP622 relied on ":=" initially, but they found some corner case with it (apparently, operator precedence related) and switched to "as" in PEP634.
- kortex 6y agoThat works too but I guess I am still getting used to the walrus operator. What really bugs me about this PEP is they are going through all this effort to introduce match but they don't have match assignments, which is personally one of my favorite things about match.