For comparison, here is an example of Python?s match-statement. Like
all the good (i.e. non-C-based) designs, the designers saw no point in
having fall-through.
This is a very simple example, involving straight matching of values
against instances of an enum. There are also more complex
pattern-matching options available.
Here?s an example that matches the type of the match-expression (not
its value) against various event subclasses:
events = iter(self.ws.events())
while True :
event = next(events, None)
if event == None :
break
For comparison, here is an example of Python?s match-statement. Like
all the good (i.e. non-C-based) designs, the designers saw no point
in having fall-through.
This is a very simple example, involving straight matching of values
against instances of an enum. There are also more complex
pattern-matching options available.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 498677:07:51 |
| Calls: | 212 |
| Calls today: | 3 |
| Files: | 910 |
| D/L today: |
31 files (22,593K bytes) |
| Messages: | 69,826 |