Last active
February 3, 2021 13:20
-
-
Save leveled/2e13c8f9225dfc200cea3154822ff740 to your computer and use it in GitHub Desktop.
Declaring variables in nim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x, y: int # declares x and y to have the type ``int`` | |
var | |
x, y: int | |
# a comment can occur here too | |
a, b, c: string | |
#Constants | |
const x = "abc" # the constant x contains the string "abc" | |
const | |
x = 1 | |
# a comment can occur here too | |
y = 2 | |
z = y + 5 # computations are possible | |
#Let statements - single assignment | |
let x = "abc" # introduces a new variable `x` and binds a value to it | |
x = "xyz" # Illegal: assignment to `x` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment