bbaldino
07/13/2019, 6:04 AMMutableMap
, overriding compute
gives the signature override fun compute(key: T, remappingFunction: BiFunction<in T, in U?, out U?>): U?
, but overriding computeIfAbsent
gives override fun computeIfAbsent(key: T, mappingFunction: Function<in T, out U>): U
(note the missing ?
after U
on the return type) but computeIfAbsent
is documented as being able to return null. is this a bug? computeIfPresent
also correctly uses U?
as the return type.bbaldino
07/13/2019, 7:06 PMU?
bbaldino
07/13/2019, 7:08 PMU
as U : Any?
in the class, explicitly returning null
from that function was giving me an erroruli
07/13/2019, 7:09 PMbbaldino
07/13/2019, 8:50 PMcomputeIfAbsent
was the same from the comment about the return value: @return the current (existing or computed) value associated with the specified key, or null if the computed value is null
uli
07/13/2019, 8:58 PMuli
07/13/2019, 8:58 PMuli
07/13/2019, 8:59 PMbbaldino
07/13/2019, 8:59 PMuli
07/13/2019, 9:01 PM