What means “_” symbol in Kotlin?

北战南征 提交于 2019-12-02 13:03:19

问题


I tried to find information what it means but I didn't. Trying to understand what it does in this code:

checkBox.setOnCheckedChangeListener { _, isChecked ->
            if (isChecked) {
                // The toggle is enabled
            } else {
                // The toggle is disabled
            }
        }

回答1:


The _ Used for

  • substitutes an unused parameter in a lambda expression
  • substitutes an unused parameter in a destructuring declaration

For more information check this Keywords and Operators



来源:https://stackoverflow.com/questions/59006347/what-means-symbol-in-kotlin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!