doc / ch.tutteli.atrium.domain.builders.utils / nullableContainer

nullableContainer

inline fun <T> nullableContainer(iterable: Iterable<T>): Iterable<T?> (source)

Turns an Iterable into an iterable with a nullable element type.

Intended to be used in conjunction with platform types such as Iterable<String!> or in other words, when you deal with Java and you want to turn a platform type into a nullable type.

Basically it is a replacement for cast but without introducing one explicitly (we only give an additional hint to the compiler that we expect a nullable type and not a non-nullable one). For instance, instead of writing getPersons() as Iterable<String?> you can write nullableContainer(getPersons())

inline fun <T> nullableContainer(arr: Array<out T>): Array<out T?> (source)

Turns an Array into an array with a nullable element type.

Intended to be used in conjunction with platform types such as Array<String!> or in other words, when you deal with Java and you want to turn a platform type into a nullable type.

Basically it is a replacement for cast but without introducing one explicitly (we only give an additional hint to the compiler that we expect a nullable type and not a non-nullable one). For instance, instead of writing getPersons() as Array<String?> you can write nullableContainer(getPersons())