Kotlin 2 · Classes and types
Add a function to an existing type
An extension function is called like a member but defined outside the class.
fun String.isPalindrome() = this == reversed()
println("level".isPalindrome())
Official Kotlin 2 documentation