Is there some clever way in Arrow to check a list ...
# arrow
l
Is there some clever way in Arrow to check a list of nullable values if any of them
!= null
Apart from the standard syntax:
Copy code
myVal1 != null || myVal2 != null || myVal3 != null
This is ok, but I would like to write something more expressive, like:
Copy code
listOf(myVal1, myVal2, myVal3).anyNotNull()
Do I have to use
Option
for this?
a
listOf(myVal1, myVal2, myVal3).any { it != null }
would work
l
Oh yes, that's quite simple ­čśä
Thank you!
a
my pleasure!
also
listOfNotNull(myVal1, myVal2, myVal3).isNotEmpty()
could work
l
I think the first one is clearer for the reader at first glance