0Pricing
Mojo Academy · Lesson

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 = 0

All lessons in this course

  1. Declaring Values with var
  2. Int, Float, and Bool
  3. Strings and Text
  4. Type Annotations That Help
← Back to Mojo Academy