Dmitry Kandalov
11/27/2018, 12:07 AMfun <T> Tree<T>.nodes(): List<Node<T>> =
when (this) {
is Node<T> -> left.nodes() + right.nodes() + this
is End -> emptyList()
}
but this is not
fun <T> Tree<T>.nodes(): List<Node<T>> =
when {
this is Node<T> -> left.nodes() + right.nodes() + this
this is End -> emptyList()
// kotlin wants `else` here
}
?