<@U2VPDH0P6> Be aware your code is not safe. I wou...
# intellij
c
@mingkangpan Be aware your code is not safe. I would rewrite this loop to avoid the
!!
m
cedric: what do you suggest, how?
c
Since the
filter
doesn't enable smartcasting, I'd loop manually and test each for
null
myself, probably with
?.let
. This way, you get rid of
!!
Copy code
widget.advertImageList?.forEach { w ->
       w.referenceImageUrl?.let { url ->
            pictureItems.add(PictureSliderAdapter.PictureItemViewModel(url, w.description ?: ""))
        } 
      }
m
okay thanks
b
There is
filterNotNull
method