Nullable and Non-Nullable types

suggest change

Normal types, like String, are not nullable. To make them able to hold null values, you have to explicitly denote that by putting a ? behind them: String?

var string        : String = "Hello World!"
var nullableString: String? = null

string = nullableString    // Compiler error: Can't assign nullable to non-nullable type.
nullableString = string    // This will work however!

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents