Take the code
class Foo {
num { _num }
construct new(num) {
_num = num
System.print("Creating foo")
}
}
var bar = [1, 2].map{|x| Foo.new(x) }.where{|x| x.num > 0}.toList
If run, it prints "Creating foo" 4 times. Intuitively I expect it to call only 2 times, and I tested the same thing using C# linq and it is called 2 times.
Is this possible to fix with how WhereSequence works?
At the very least it's something to look out for in case your construction is resource intensive.