Kotlin extension function

Kotlin gives the programmer the ability to add more functionality to the existing classes, without inheriting them. This is achieved through a feature known as extensions. When a function is added to an existing class it is known as Extension Function.

How add Kotlin extension function

To add an extension function to a class, define a new function appended to the “class name”. To declare an extension function, prefix its name with a receiver type, which refers to the type being extended.

Change “Date” format with extension function

Visit Now