Question - What are the extension functions in Kotlin?
Answer -
Extension functions are like extensive properties attached to any class in Kotlin. Extension functions are used to add methods or functionalities to an existing class even without inheriting the class. For example: Suppose, we have views where we need to play with the visibility of the views. So, we can create an extension function for views as follows:
fun View.show() {
this.visibility = View.VISIBLE
}
fun View.hide() {
this.visibility = View.GONE
}
and to use it, we use, like,
toolbar.hide()