Can someone help me understand why the author is making it sound like
def foo(bar, baz):
if bar == “thing1”
baz.methodFromTypeX()
elif bar == “thing2”:
baz.methodFromTypeY()
is something super complicated? Like I get that in some respects the type signature for this method is funky and seems nigh impossible to encode in a type system (which I guess is the point) but this kind of thing is not at all hard to grok as a human.
I think if you settle for the args being combined into a tuple you could essentially create a tagged union and the type checker should be able to refine off the comparison.