Type Annotations
In Cangjie, you can explicitly specify a variable's type using : Type after the variable name. Type annotations make code intentions clearer, and the compiler checks whether the assigned value matches the declared type, catching type errors at compile time.
Cangjie is a statically typed language, where every variable has a definite type. Common basic types include: Int64 (64-bit integer), Float64 (64-bit floating-point), String (string), Bool (boolean, only true and false). Type names starting with a capital letter is Cangjie's naming convention.
The type annotation comes after the variable name, which differs from the traditional C/Java style (type first). The benefit of this design is that even with type annotations, the variable name remains at the front, highlighting the core information of "name", making it easier to quickly locate variable names when reading code.
Try changing a type annotation to an incorrect type (e.g., changing Int64 to String) and observe what error the compiler reports.