Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Created November 17, 2019 20:59
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 magdamiu/ab7cd1d624049cb1a5f3e831773210a3 to your computer and use it in GitHub Desktop.
Save magdamiu/ab7cd1d624049cb1a5f3e831773210a3 to your computer and use it in GitHub Desktop.
val vs var
// immediate assignment
val countOfEvenNumbers: Int = 10
// `Int` type is inferred
var sumOfNumbers = 0
// type required when no initializer is provided
var countOfPrimeNumbers: Int
// deferred assignment
countOfPrimeNumbers = 3
countOfPrimeNumbers = 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment