I'm trying to read a list of string from a file, which is structured as a list:
ElemA
ElemB
ElemC
I need to save into this variable, which is defined as:
private var history: Array<out String>?
I made this method, but it doesn't works because it requires an Array? as output, but it founds an Array<(out) Any!>!
private fun loadHistory(): Array<out String>? {
val list = ArrayList<String>()
File("history").forEachLine { list.add(it) }
return list.toArray()
}
How can I solve?
list.toTypedArray()instead oflist.toArray()