Non-deterministic output to console from stream() operation

S

san_francisco

Guest
I have strange result from my simple code:

val custom_list = listOf(CUSTOM_TAG+"first", CUSTOM_TAG+"second", CUSTOM_TAG+"third")
fun randomScore(){
val myStream = custom_list.stream()
myStream.filter { e ->
println(CUSTOM_TAG+"text")
e.contains("third")
}.forEach { e -> println(e) }
}


Somethimes I get:

1000_text
1000_text
1000_third


and another time I get

1000_text
1000_text
1000_text
1000_third


Could someone can explain why I get random result and how to fix it ?

Continue reading...
 
Top