Scala thread :: filterNot lazy
Simple example:
val set = Set(0, 1, 2)
Stream.from(0).filterNot(set).head
The cycle seems to be forever; but the following code works:
Stream.from(0).filter(!set(_)).head
I use
Scala code runner version 2.11.4 -- Copyright 2002-2013, LAMP/EPFL
This is mistake? or any reason for this?
+3
source to share
1 answer
As per the ticket: https://issues.scala-lang.org/browse/SI-8627 the filterNot implementation that applies to Streams is not lazy, which would show up in what you see,
So there seems to be a bug, and according to the tickets, no fixes were found to fix it without any significant penalties for other collections or a binary compatibility violation, so it seems to target the main release (2.12)
+3
source to share