In the Kotlin code, I want to add two fields to the map like this:
val myMap: Map<Type, List<Parameter>> = mapOf(
Pair(Type.POST, request.postDetails.postParameters),//postDetails can be nullable
Pair(Type.COMMENT, request.commentDetails.commentParameters)//commentDetails can be nullable
)
The above code is showing error at postDetails.postParameters and commentDetails.commentParameters because they can be nullable.
How can I create a map inplace like this instead of creating a variable and updating it where I want to keep the pair only in the case the value is not null?