The essential ingredient of every programming language is variable. This post is part of the functional language series.
Last time we learned how to use variables in Elixir. Let’s explore how we can use variables in Elm.
Elm is the same as Elixir, a dynamically typed programming language. That means that variable type is auto determined from variable value. What is useful is that Repl echoes the assigned type.
Variable name should start with a lower letter, otherwise, after the second enter in repl, you will get the following error:
This is less scary than Elixir’s error but still cryptic error that does not reveal the root cause of the problem. For now, let’s conclude that writing a grammar parser is really hard.
A variable name should start with a lower letter.
As in Elixir, variables are also immutable. When you define a variable, you reserved in the computer memory location of byte size that is required for variable type. You reference that memory location using the variable name. By assigning a new value to the same variable name, you do not overwrite an existing location, you reserve a new memory location.
- dynamically typed language
- variable name convention
- compare it to Elixir
After you explain in your own words these topics to your rubber duck, it is time for homework.
Bind to the variable named vat, your country VAT amount for the basic Rubik cube. What is the vat data type?