我想从StringArray
获取Resources
并将其转换为MutableList
我尝试了以下代码
var morality = mutableListOf(activity.resources.getStringArray(R.string.morality))
但它给我一个错误说
Type mismatch
Required: String?
Found: ArrayOut<(out)String!>!
答案 0 :(得分:6)
我用
解决了这个问题var namesAndAges = ["Tom": 25, "Michael": 35, "Harry": 28, "Fabien": 16]
var namesOfAge = namesAndAges.filter { $0.value > 18 }.map{ $0.key }
print(namesOfAge)