Skip to content

Instantly share code, notes, and snippets.

@harshgmp
Created August 31, 2019 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshgmp/ece339d8673392a68892ef30ef772d05 to your computer and use it in GitHub Desktop.
Save harshgmp/ece339d8673392a68892ef30ef772d05 to your computer and use it in GitHub Desktop.
fun main() {
val variable1 = 10
println(variable1)
//variable1 = 20 //Illegal Expression because val can not be reassigned
var variable2 = 20
println(variable2)
variable2 = 30
println(variable2)
//printNum(null) // Illegal Expression because variable a is not nullable
printNum(20)
printNullNum(null)
}
fun printNum(a: Int){
println(a)
}
// Notice the question mark after Int which represents that vara is nullable
fun printNullNum(vara: Int?){
println(vara)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment