tomo-koans/lesson-templates/lesson-03-variables.tm

29 lines
540 B
Plaintext
Raw Normal View History

2025-03-24 15:06:22 -07:00
# Variables
func main():
# Variable declarations use `:=` and do not
# require you to specify a type explicitly:
x := 123
# To assign a new value, use `=`
x = 999
# You can also use update assignments like `+=`
x += 1
>> x
= 1000
# Variables are strongly typed, so you can't
# assign different types to the same variable:
2025-03-25 13:37:36 -07:00
x = "hello" # <-- This will error, comment it out or fix it
2025-03-24 15:06:22 -07:00
# Declare a variable called `y` and give it the
# value "okay"
2025-03-25 13:39:55 -07:00
???
2025-03-24 15:06:22 -07:00
>> y
= "okay"