dave08
10/03/2017, 12:18 PMoperator iterator()
that returns a custom iterator that implements operator hasNext()
and operator next()
, to return a List? It seems that currently the only way is to make a mutable list and then for (e in iterator) list.add(e)
...?fourlastor
10/03/2017, 12:34 PMList
constructorval list = List(count, { index -> valueFor(index) })
dave08
10/03/2017, 12:39 PMin
to work...fourlastor
10/03/2017, 12:42 PMIterable
, let me look up the functiontoList()
dave08
10/03/2017, 12:46 PMpublic inline fun <T> Iterable(crossinline iterator: () -> Iterator<T>): Iterable<T> = object : Iterable<T> {
override fun iterator(): Iterator<T> = iterator()
}
Doesn't help in this case... since my iterator() function doesn't return a real Iterable, oh well I guess back to the harder way... 😢