The Kotlin extension function is a new feature of Kotlin. Without creating an object of class. It is known as an extension function. To add an extension function to a class define a new function appended to the class name as shown in the following example.
Example:
Output
Extended library class using an extension function
Kotlin not only allows the user-defined classes to extend but also the library classes. The following example of library functions.
Example:
Output
Happy coding!