I hope to get a name array from a list of MSetting, at present, I use Code A to do it, but it's too complex, is there a simple way to do it?
Code A
fun getName(aList:List<MSetting>): Array<CharSequence>{
if (aList.isEmpty()){
return emptyArray<CharSequence>()
}else{
var aa=Array<CharSequence>(aList.size,{""})
for (index in aList.indices){
aa[index]=aList[index].name
}
return aa
}
}
Data
data class MSetting (
var _id: Long,
var name: String,
var createdDate: Long,
var description: String
)