I tried these in Kotlin REPL
var listA = listOf(null ,null)
var listB = [null, null]
The first line works fine as expected. On displaying listA I get:
[null, null]
第二行抛出以下错误:
error: cannot use 'Nothing?' as reified type parameter
var listB = [null,null]
^
error: unsupported [Collection literals outside of annotations]
var listB = [null,null]
^
error: unsupported [Array<Nothing> in return type is illegal]
var listB = [null,null]
^
当我try 使用非空类型时,
var listC = [1,2]
我得到这个错误:
error: unsupported [Collection literals outside of annotations]
var listC = [1,2]
^
我是Kotlin 的新手.有人能解释一下这是怎么回事吗?