5 ms·
I would counter that isinstance() checking is - at least in the general case - an antipattern. Better to check that the object you've been passed implements th
by chucksmash 12y ago
I would counter that isinstance() checking is - at least in the general case - an antipattern.
Better to check that the object you've been passed implements the interface you need rather than reasoning about its inheritance chain. Duck typing!
- Roboprog 12y agoAs much as I hate the Java language, "isinstance" does allow you to check for an interface, not just a class.
- marcosdumay 12y agoSome times one wants classes to be semantic, not only structural. That means that when the developer writes "class C(Foo)" he means something different than writting "class C(Bar)" even if both classes implement the same methods.