I’ve noticed that. The extension function map supports primitive arrays (such as IntArray, ByteArray, LongArray, etc.) while mapNotNull doesn’t support.
I am actually wondering whether this is an intentional decision with some consideration, or it is just hasn’t been implemented yet?
Primitive arrays cannot have null values, in the same way the you cannot assign null to a variable with a primitive type int
.
Check this documentation: https://kotlinlang.org/docs/reference/basic-types.html
1 Like
Refer to the definition of mapNotNull
:
Returns a list containing only the non-null results of applying the given transform function to each element in the original array.
While I understand that primitive arrays can’t have null values, but the result of the transform
function can be null. Thus nothing prevents mapNotNull from being implemented for primitive arrays.
1 Like
Oh, you are right. I misunderstood what you where trying to say.