首页 > 解决方案 > operator "it" in kotlin. PopupMenu(this, it)

问题描述

I have this line of code and I can not find any information what does mean operator "it" which is in brackets. How does "it" usually used? val popupMenu = PopupMenu(this, it)

The tutorial where I found this line of code (time - 3:20) https://www.youtube.com/watch?v=ncHjCsoj0Ws

标签: androidkotlin

解决方案


it is an implicit name of a single parameter

It's very common that a lambda expression has only one parameter.

If the compiler can figure the signature out itself, it is allowed not to declare the only parameter and omit ->. The parameter will be implicitly declared under the name it

In your example it means the view that was clicked


推荐阅读