How do I distinguish a global variable from a local one with the same name in Kotlin?

前端 未结 1 1785
温柔的废话
温柔的废话 2021-01-21 03:00

I\'m learning Kotlin, and in my project I have something like the following

Utils.kt:

var weightInKilos = 100.0

//should multiply the above var
fun doSo         


        
1条回答
  •  失恋的感觉
    2021-01-21 03:46

    Use the package name as the identifier. If the enclosing package for Utils.kt file is com.example, you would use com.example.weightInKilos = weightInKilos * multiplier.

    Thank you Android Studio autocomplete.

    0 讨论(0)
提交回复
热议问题