I have a really hard time recognizing when I shoul...
# getting-started
h
I have a really hard time recognizing when I should be uses sequences vs when i shouldn't. Fundamentally, I understand that sequences are lazy and execute each element at a time through to the end, and you can conditionally escape the sequence to make things more efficient.... ....but there's actually few common use cases (in my experience) in which they would benefit me. How am I supposed to even keep them in mind?
👍 1
righto.
yeah, programming can get complicated, huh!
t
I often switch to a sequence when I have to apply more than 2 operators on it (
map
,
filter
, etc.), especially with large collections. One use case where sequences are really useful in my opinion is when you need to
skip
or
take
a given number of elements. In most cases, @Ruckus's answer is the way to go.