https://kotlinlang.org logo
Title
r

reik.schatz

02/11/2019, 1:00 PM
val items = Arrays.asList("a", "b", "c")
// doesn't compile because it is Stream<String?>!
val stream: Stream<String> = items
    .stream()
    .map { item ->
       // call that returns nullable, i.e. String?
    }
    .filter(Objects::nonNull)
u

utikeev

02/11/2019, 1:05 PM
Does
items.filterNotNull().stream()
suit?
r

reik.schatz

02/11/2019, 1:08 PM
so my actual use case is a bit different, it’s more like
h

hudsonb

02/11/2019, 1:08 PM
!!
is sometimes a necessary evil when working with platform types:
val stream: Stream<String> = items
            .stream()
            .filter(Objects::nonNull)
            .map { it!! }
r

reik.schatz

02/11/2019, 1:09 PM
cool, thats probably ok for me
thanks