orDefault

fun <T> T?.orDefault(default: T): T

when variable is null default value maintained.

Example:

val str: String? = null
str.orDefault("def") // def

Since

1.1.0

Return

T value or default