Literals

Numeric literals can be type annotated by adding the type as a suffix. As an example, to specify that the literal 42 should have the type i32, write 42_i32.

The type of unsuffixed numeric literals will depend on how they are used. If no constraint exists, the compiler will use felt252 by default.

fn main() {
    // Suffixed literals, their types are known at initialization
    let _x = 1_u8;
    let _y = 2_u32;
    let _z = 3_i32;

    // Unsuffixed literals, their types depend on how they are used
    let _i = 1;
}