conner
10/18/2021, 7:00 PMinstanceof
checks -- so naturally various stack overflow answers mentioned "code smell", and i'm wondering if there's truth to that 🙂
sealed class Node
data class Leaf(x: Int): Node()
data class Tree(left: Node, right: Node?): Node()
Alex Prince
10/18/2021, 7:04 PMconner
10/18/2021, 7:15 PMinstanceof
is much more optimized than it used to be, so maybe this is more FUD than anythingdmitriy.novozhilov
10/18/2021, 8:19 PMStephan Schroeder
10/19/2021, 6:51 AMinstanceof
-checks of normal classes in Java is a code smell, is
-checks of sealed classes in Kotlin isn't. Mostly because the compiler can check that you covered all cases, I guess. (maybe also because of smart cast 🤔)conner
10/19/2021, 8:48 PM