#
- Single-line comment.
##
- Multi-line comment.
;
- Statement separator (usually optional).
Example:
# This is a single-line comment
## This is a
## multi-line comment
let x = 5; echo x # Statement separator used here
A concise reference for the Nim programming language, covering syntax, data types, control flow, and advanced features for quick lookup and efficient coding.
Example:
|
Example:
|
Example:
|
|
Integer (platform-dependent size). Example: |
|
Signed integers of specific sizes. Example: |
|
Unsigned integer (platform-dependent size). Example: |
|
Unsigned integers of specific sizes. Example: |
|
Floating-point numbers. Example: |
|
Boolean (true or false). Example: |
|
Single character. Example: |
|
Sequence of characters. Example: |
Example:
|
Example:
|
Example:
|
|
Iterating over a range or collection.
|
|
Looping while a condition is true.
|
|
Exits the current loop.
|
|
Skips the current iteration and continues with the next.
|
Syntax:
|
Parameters can have default values:
|
Discarding return values:
|
Example:
|
Array access:
|
Sequence length:
|
|
Collection of named fields with different types.
|
|
User-defined type with fields and methods (similar to classes in other languages).
|
Example:
|
Generic procedures and types allow you to write code that works with multiple types. Example:
|
|
Evaluate code at compile time. Useful for generating code or performing calculations at compile time.
|
|
Code generation mechanism. Templates are expanded at compile time.
|
|
More powerful than templates. Macros can manipulate the abstract syntax tree (AST) of the code.
|
Example:
|
Example:
|