hd-lang

Tour · 4 of 25

A number never changes type on its own, so every conversion is in the code

A number type names its width: i32, i64, u8, f64, and usize for lengths and indices. hd never converts between them for you, not even from i32 to the wider i64, so i64(quantity) shows each place a value changes type. A literal takes its type from its use, and _ groups digits, as in 1_250. Text that should be a number is parsed, and parsing can fail, so text.parse::[i32]() gives a Result. A string interpolates $name and ${expression}; a $ before anything else is plain text, so $${...} prints a dollar sign before the value. A range index slices: entry[0..3] is the first three bytes, and entry[4..] the rest from byte 4.

Run: Ctrl+Enter · Pages: Alt+← Alt+→