Kotlin - Extension for final class

Viewed 4575

Is it possible to create extension of final classes like String? Like in swift it is possible to add additional methods inside a extension of final class.

For an example - I would like to create a method in String extension which will tell me String have valid length for password.

 val password : String = mEdtPassword!!.getText().toString()

 // how to define haveValidLength method in extension
 val isValid : Boolean = password.haveValidLength()

Note - That example is just for a sake to understand usability of extension, not a real scenario.

3 Answers
Related