Similarly to C# or Swift, Kotlin supports extension functions. Extension functions allow you to extend the behavior of an existing type, even if you don't own that type. This can be extremely useful when working with cumbersome APIs or when building custom DSLs. Extension functions can be defined in any Kotlin file, but require special syntax.
The following snippet is taken from the Kotlin Standard library and demonstrates how extension functions can be used to extend common classes as well:
// forEach is defined as an extension function CharSequence
inline fun CharSequence.forEach(action: (Char) -> Unit)
The forEach function does not exist as a method on CharSequence but can be invoked as if it were a method. This not only gives the language's developers the freedom to extend classes as needed, but any developer is now free to modify existing types as they see fit.