mean, “any function that takes TreeNode<T> and return Unit can now be referred to as
Visitor<T>
?
so instead of writing
Copy code
fun search(printResult: (TreeNode<T>) -> Unit)
I write
fun search(visit: Visitor<T>)
d
Dave K
07/04/2021, 8:14 PM
Yes and the compiler will replace the Visitor<T> with the correct type. It doesn’t create a new type just a simpler short hand for your code. https://kotlinlang.org/docs/type-aliases.html