Closed
Description
What happened
Calling sort on a Seq evaluated the Seq immediately even though I expect it to not evaluate until the Seq is actually used.
How to reproduce
When I run:
Seq([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).filter(x => {
console.log('filtering');
return x >= 5;
});
I see no output, which is expected behavior. However, when I append a .sort()
after the filter call:
Seq([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).filter(x => {
console.log('filtering');
return x >= 5;
}).sort();
I receive the following output:
filtering
filtering
filtering
filtering
filtering
filtering
filtering
filtering
filtering
filtering
Is this intended behavior? If so, do you have any suggestions for combining sort functions with lazy evaluation?
Metadata
Metadata
Assignees
Labels
No labels