android - 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
解决方案
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 nameit
In your example it
means the view that was clicked
推荐阅读
- python - 如何使用 Tkinter Entry 输入多行?
- swift - 一个 UILabel 和两个 NSMutableAttributedString
- c# - 返回 Json 结果格式时如何解析未定义的值?
- html - 如何在 HTML/CSS 中使用 % 中的位置方法来更精确地调整显示器分辨率?
- hpc - 如何在 slurm 中找到导致节点故障的 jobId?
- c# - ServiceStack ORMLite 如何在查询中解析 JSON 数据
- asp.net-core - 如何在下面的代码中返回成功以使用 asp.net 核心?
- stripe-payments - 订阅设置试用期时如何防止在条带中创建重复订阅
- python - 通过 Jupyter Notebooks 的 psycopg2 psql 命令不起作用
- sql-server - 查找整个数据库中表的每一列(不包括空白和空值)中的记录数