published: 28th of July 2021
Like most languages, variables in Crystal are defined with the = operator.
# Create a string variable
stuff = "stuff"
# Deduce the type of a variable.
typeof(stuff) # => String
# Explicitly define the type of a variable.
stuff : String
# Assign "stuff" value to the stuff variable
stuff = "stuff"
# Define a variable type and assign a value
stuff : String = "stuff"
# Define a constant
THINGS = "things"
https://pragprog.com/titles/crystal/programming-crystal/
https://crystal-lang.org/reference/conventions/coding_style.html