The Elvis operator (?:) returns an alternative value if a null value is used in an expression:
val result2: String = nullableCupcake?.eat() ?: ""
If nullabluCupcake?.eat() is null, the ?: operator will return the alternative value "".
Obviously, the Elvis operator can be used with a chain of safe calls:
val length2: Int = nullableCupcake?.eat()?.length ?: 0