, : ?:
:
first operand ?: second operand
:
first operand
, . , second operand
. , , , .
( ):
fun retrieveString(): String {
var nullableVariable: String? = getPotentialNull()
return nullableVariable ?: "Secondary Not-Null String"
}
, getPotentialNull
, retrieveString
; , "Secondary Not-Null String"
.
, , .
Kotlin second operand
, , throw Exception
return nullVariable ?: throw IllegalResponseException("My inner function returned null! Oh no!")
Elvis Operator .
: , . , . Android Kotlin. 2017. Packt Publishing