18 May
2021
18 May
'21
8:14 a.m.
On Tue, May 18, 2021 at 8:26 PM Ir. Robert Vanden Eynde
About matching, switch case does not exist in python because if/elif/else cascade exists
if (x := 5) in irange(1, 5): println(stuff1) elif x == 8 println(stuff2) else: println(stuff3)
Hmm, switch statements exist in a lot of other languages that also have if/elif/else. A closer comparison, for a lot of switch blocks, is a dispatch table based on a dictionary. For more complex switching, there's the concept of pattern matching, which has been debated on-and-off for a good while, and is now being added to the language; but the main reason for not needing a classic switch block is probably the dict lookup option. ChrisA