https://kotlinlang.org logo
#announcements
Title
# announcements
a

Alexjok

06/07/2019, 3:36 PM
Hello, it is possible do parallel filter via collection stream?
g

gildor

06/07/2019, 3:48 PM
Are you talking about Java streams?
There is parallel() operator for java streams
k

Krotick

06/07/2019, 3:49 PM
a

Alexjok

06/07/2019, 4:04 PM
Okey, thx guys. I think mb in kotlin we have another way for it)
k

Krotick

06/07/2019, 4:07 PM
Another way is to use sequences, which is more idiomatic to Kotlin (or so I think), and achieves the same function as streams
g

gildor

06/07/2019, 4:07 PM
If you use java streams there is no other way. You can achieve it using coroutines
Kotlin sequences is syncronous only abstraction, there is no way to make it parallel, at least in some easy way without some fork-join abstraction
a

Alexjok

06/07/2019, 4:09 PM
Andrey, some samples? How i can make it with coroutines? Interesting
g

gildor

06/07/2019, 4:09 PM
Depends on your case, there are different ways, I would recommend to check coroutines guides first
a

Alexjok

06/07/2019, 4:16 PM
Okay, thx now i have some ideas)
g

gildor

06/07/2019, 4:56 PM
Just want to mention that Flow is not the only way, but yes Flow is most suitable abstraction for this. But again, I would recommend to read official guides first, to have understanding of coroutines
80 Views