Type Annotations That Help
Add types so Mojo can optimize and catch errors.
What Is a Type Annotation?
A type annotation states a value's type right in the declaration, so both you and Mojo know exactly what it holds.
Annotating a var
Add a colon and the type after the name. Here : Int promises that count will only ever hold whole numbers.
var count: Int = 0All lessons in this course
- Declaring Values with var
- Int, Float, and Bool
- Strings and Text
- Type Annotations That Help