CLOVIS
01/03/2024, 1:24 PMoperator fun <T> List<T>?.plus(element: T) =
if (this != null) this + element
else listOf(element)
I've seen (nullableList ?: emptyList()) + element
being used in a few places, and I don't think it's particularly readable (and it adds some useless logic when concatenating the empty list).mbonnin
01/03/2024, 1:34 PMnullableList.orEmpty()
CLOVIS
01/03/2024, 1:35 PMKlitos Kyriacou
01/03/2024, 2:08 PMlist?.plus(elem) ?: listOf(elem)