Skip to content

Commit 66ea094

Browse files
committed
Actually, we don't care about the return type of the actions at all.
1 parent 003e2a0 commit 66ea094

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ with switch(value) as s:
6565

6666
**Warning / open for debate**:
6767

68-
I'm a little unsure what is the right way to handle this
68+
I'm a little unsure what is the right way to handle this.
6969
On one hand, reading `case(range(1,5))` seems like it should
7070
include `1, 2, 3, 4, 5`. But `list(range(1,5))` is `[1,2,3,4]`.
7171
So that would be inconsistent.

switchlang.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Here is a first pass implementation at adding switch
2-
from typing import Callable
2+
from typing import Callable, Any
33

44

55
class switch:
66
def __init__(self, value):
77
self.value = value
88
self.cases = {}
99

10-
def default(self, func: Callable[[], None]):
10+
def default(self, func: Callable[[], Any]):
1111
self.case('__default__', func)
1212

13-
def case(self, key, func: Callable[[], None]):
13+
def case(self, key, func: Callable[[], Any]):
1414
if isinstance(key, range):
1515
for n in range(key.start, key.stop + 1, key.step):
1616
self.case(n, func)

0 commit comments

Comments
 (0)