We can define a variable considering whether it can store a null value or not by using the ?
operator at the end of the variable's type such as var button: Button? = null
.
I know that when we will be using the button variable we have to use the safe call operator ?
, but that is different from the operator we used in var button: Button? = null
Now, how should I pronounce this ?
operator?
CodePudding user response:
I would call it the "nullable/nullability operator". In the documentation, you find some references to it (associated with other operators, like as
), although it might not have an official name.
"Safe" (nullable) cast operator
In the Keyworks and Operators section in the documentation, you will find a reference to it as:
? marks a type as nullable