Closed cigaly closed 7 years ago
Thank you very much for reporting. Will look into this immediately.
It might well be that jOOλ could optimise the lazy evaluation of the Seq.iterate()
calls (currently passing this through to Stream
) to avoid the application of the call array[-1]
, but in any case, defensive programming would probably suggest this implementation, instead:
UnaryOperator<Integer> iterate = x -> x >= 0 ? array[x] : x;
You are right, it could be coded that way, still, I would not call that a feature.
still, I would not call that a feature.
Well, I didn't, did I? :)
No, that's true :-)
This issue is a duplicate of #309 :) Fortunately, it's trivial to fix - see https://github.com/jOOQ/jOOL/issues/309#issuecomment-298250192.
That's correct. With your proposed change thsi is working properly.
This test will generate ArrayIndexOftOfBoundsException:
After filter predicate.test(-1) returns false, iterate.apply(-1) should newer be called.
Here is equivalent code in scala that is working as expected: