-
Notifications
You must be signed in to change notification settings - Fork 0
Kotlin's invoke Operator function
Rajesh Khadka edited this page Dec 7, 2018
·
2 revisions
class ReleaseHandler {
operator fun invoke() {
print("invoke method called")
}
}
var release = ReleaseHandler()
Output: invoke method called
If you want to execute a function without specifying the function name then you can define invoke the function as:
operator fun invoke() {}
This will be a great trick in case of a class having the single method.
References: