是否表示列表项可以是String
还是非String
?我在以下代码中找到了用法:
class KotlinGreetingJoiner(val greeter: Greeter) {
val names = ArrayList<String?>()
fun addName(name: String?) {
names.add(name)
}
fun getJoinedGreeting(): String {
val joiner = Joiner.on(" and ").skipNulls()
return "${greeter.getGreeting()} ${joiner.join(names)}"
}
}