lang/nim/ NimInActionSummary1


Keywords

if case of when var let proc type object try except finally

Syntax

echo ("Output:", # note that punctuation comes before the line break
  5)
# Single-line comment
#[
Multiline comment
]#
when false:
  echo("Commented out")

Basic types

int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64
let x = 42 # or 0x42 or 0x42 or 0b10101

float float32 float64
let x = 1'f32 # or 1'f64

bool
let x = true # or false

char
let x = 'A' # ascii only -- use Rune in unicode module for unicode chars
# \r \c \l \t \\ \' \"

string 
let x = "Hello world" # strings can hold utf8, but unicode module is needed to manipulate such strings
let y = r"C:\hello\world" # like in Python
let z = """hello
world""" # like in Python

let, const, var

let x = 42
x = 43 # error -- x is immutable
var y = 42
y = 43 # ok
const z = 42 # must be computable at compile time

stropping

var `var` = hello
echo(`var`) # prints "hello"