Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 504 Bytes

Extension functions over usual class.md

File metadata and controls

27 lines (18 loc) · 504 Bytes

Extension functions over usual class

The function can be used on a class object.

Explanations

Let's declare an extension function over a custom type in Kotlin code:

//ExtensionFunctionOverUsualClass.kt

class UsualClass {
}

fun UsualClass.extensionFunction() {
    println("Successful call")
}

On the Swift side, we can use this function similarly to Kotlin, on an object of the desired class:

UsualClass().extensionFunction()

Table of contents