4 ms·
You can annotate OR types in python so in this case you could do def fooify(x: int | list[int])
by yoyohello13 3y ago
You can annotate OR types in python so in this case you could do
def fooify(x: int | list[int])
- pharmakom 3y agoBut if x is an int, the result is an int If x is a list, the result is a list I don’t think that the type system can describe this.
- olejorgenb 3y agoIt can: https://news.ycombinator.com/item?id=39179144 https://news.ycombinator.com/item?id=39179144