Invoke Operator & Operator Overloading in Kotlin

前端 未结 3 587
北海茫月
北海茫月 2020-12-30 23:39

I get to know about the Invoke operator that,

a() is equivalent to a.invoke()

Is there anything more regarding Invoke operator the

3条回答
  •  余生分开走
    2020-12-31 00:12

    If you have some Python background,

    you can think invoke in Kotlin as __call__ in Python.

    By using this, you can "call" your object as if it's a function.

    One difference is: you can overload invoke, but there is no official way to overload methods in Python.

提交回复
热议问题