Let's say there is a function that returns a single nullable return value. For instance:
fun getItem(): String?
I'd like to create a new list of items by calling this function until it returns null.
My idea would be to write an iterator that iterates the return value until it's null. However, is there a more elegant or idiomatic way to approach this issue?