Extension Functions
Explore the extension functions and learn how to use them to extend the functionality of a class in Kotlin.
We'll cover the following...
Sometimes, we want to extend the functionality of a class that is declared final
. For example, to have a string that has the hidePassword()
function.
One way to achieve that is to declare a class that wraps the string for us:
Press + to interact
data class Password(val password: String) {fun hidePassword() = "*".repeat(password.length)}
This ...