Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save systemhalted/22f5d1a13d0b5795f35da65b9d4d3aaf to your computer and use it in GitHub Desktop.
Save systemhalted/22f5d1a13d0b5795f35da65b9d4d3aaf to your computer and use it in GitHub Desktop.
var rainbowColor : String = "Blue"
rainbowColor = "Violet"
rainbowColor
Violet
val blackColor : String = "Black"
blackColor
Black
blackColor = "Blue"
error: val cannot be reassigned
blackColor = "Blue"
^
rainbowColor = null
error: null can not be a value of a non-null type String
rainbowColor = null
^
var greenColor : String? = null
var blueColor = null
greenColor
null
greenColor = "Green"
greenColor
Green
var listOfElements: List<String>? = null
var listOfElements1 : List<String?> = listOf(null, null)
listOfElements
listOfElements1
[null, null]
var nullTest : Int? = null
println( nullTest?.inc()?: 0)
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment