var, final, and const Explained
Choose between mutable, run-time, and compile-time values.
Three Ways to Name a Value
In Dart you store data in named boxes called variables. The keyword you pick decides whether that box can ever change.
Meet var
Use var when a value will change later. Dart still figures out the type for you, so var is convenient and safe.
var score = 0;
score = 10;All lessons in this course
- var, final, and const Explained
- The Core Types: int, double, String, bool
- Type Inference vs Explicit Types
- The dynamic and Object Types