Kotlin: using extensions
Example:
fun String.hasSpaces(): Boolean {
return this.contains(" ")
}
Kotlin allows you to add new functions to existing types without modifying them.
Solution:
val hasSpaces = "Hello World".hasSpaces()
Example: Solution:Kotlin: using extensions
Kotlin allows you to add new functions to existing types without modifying them.
fun String.hasSpaces(): Boolean {
return this.contains(" ")
}
val hasSpaces = "Hello World".hasSpaces()