https://kotlinlang.org logo
Title
r

redrield

09/23/2018, 10:21 PM
Could someone elaborate on where/when I should be using Sequence<*> vs Collection<*>? IntelliJ has started giving me lints recommending that a call chain should use Sequence, but I'm still confused as to when I should use that. I know that Sequences are lazy and Collections are eager, but I'm not sure when to use either
v

Vladyslav Sitalo

09/23/2018, 10:34 PM
In your example, I don’t believe
toList
is necessary
To answer a more general question - sequence can potentially give you better results on long list of transformations/large collections.
k

karelpeeters

09/23/2018, 10:41 PM
Explained here as well, under "Quick Fix to convert chains of collection functions into sequences": https://blog.jetbrains.com/kotlin/2018/09/kotlin-1-2-70-is-out/