Version: 1.1.0

Types and literals cheat sheet

How to write numbers, vectors, and text.

Essentials

  • 42 is an integer literal. 42.0 is a float literal.
  • Int and Float64 are the default stored types.
  • SIMD[DType.float32, 4] is four 32-bit floats.
  • Strings use double quotes. Adjacent string literals concatenate.
  • None and Optional are different ideas. None fills an optional.

Example

def main():
    var v = SIMD[DType.float32, 4](1, 2, 3, 4)
    print(v[0])

Keep in mind

Do not store a wide literal into a narrow dtype without deciding the rounding.