typestar

Basic types in Odin

Sized integers and floats, a rune, and a bool for the lighthouse log.

package main

import "core:fmt"

main :: proc() {
    // Sized integers and floats; int is the word-size default.
    crew: u8 = 12
    depth: i32 = -180
    ratio: f32 = 42.75

    // rune is a Unicode code point; strings are immutable UTF-8.
    initial: rune = 'G'
    watching := true

    fmt.println("crew", crew, "depth", depth, "ratio", ratio)
    fmt.printfln("initial %c, storm watch %t", initial, watching)
}

How it works

  1. u8, i32, and f32 size the crew, the depth, and the ratio exactly.
  2. rune is a Unicode code point; strings are immutable UTF-8.
  3. %c and %t print the rune and the bool in the closing report.

Keywords and builtins used here

The run, in numbers

Lines
17
Characters to type
383
Tokens
76
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 65 seconds.

Type this snippet

Step 3 of 3 in Values, step 3 of 27 in Language basics.

← Previous Next →