Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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