|
|
|
|
|
by asdf1234
3917 days ago
|
|
I haven't played with Kotlin in a while but if you want collection operations to be lazy you have to explicitly convert it to a sequence. So your example would be something like: ints.asSequence().filter { it > 0 }.map { it * it }
and then you can convert it to a concrete collection type with toList, toHashSet, toArrayList etc. |
|
Why would they advertise chaining together sequence operations like this as being LINQ-like (or like Clojure and other functional languages) when it's eager by default? What is gained by making these eager by default?
It just seems like a poor choice to me. That's a shame, because I feel like it's otherwise a pretty well-designed language.