在下面的代码中,我必须在=之前添加空格,为什么呢?
我认为private val listofMDetail: MutableList<MDetail>=
(=前没有空格)可以,但是实际上,Android Studio 3.1.3给我一个错误。
private val listofMDetail: MutableList<MDetail> = //I have to add space before =
try{
myGson.fromJson<MutableList<MDetail>>(mJson)?: mutableListOf<MDetail>() //Load
}catch(e:Exception) {
e.message?.let{ logError("Paser: "+it)}
throw Exception(e)
}
该符号>=
被读取为大于或等于,这就是为什么编译器显示错误的原因Expecting a '>'
。
只需按照Kotlin
Google维护的样式指南中的建议添加空间:https : //android.github.io/kotlin-guides/style.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句