E0065#
警告名称:prefer_readonly_array
对只读数组字面量建议使用 ReadOnlyArray。
当编译器推断数组字面量只读使用时发出此警告。建议使用 ReadOnlyArray 更清晰表达意图。
错误示例#
test {
let xs = [1, 2, 3]
inspect(xs[0], content="1")
}
建议#
将数组字面量注解为 ReadOnlyArray:
test {
let xs : ReadOnlyArray[Int] = [1, 2, 3]
inspect(xs[0], content="1")
}