Skip to content

Instantly share code, notes, and snippets.

@hgarcia
Created March 19, 2012 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgarcia/2093388 to your computer and use it in GitHub Desktop.
Save hgarcia/2093388 to your computer and use it in GitHub Desktop.
Learning Erlang 3 Variables
1> 1 + 1.0.
2.0
2> 2.0 + 1.
3.0
3> 4 + 45.
49
4> 45 /0.5.
90.0
5> 2.0 + a.
** exception error: bad argument in an arithmetic expression
in operator +/2
called as 2.0 + a
7> [A,B,C] = ["Keep", "it", "simple"].
["Keep", "it", "simple]
8> A.
"Keep"
9> B.
"it"
10> C.
"simple"
%% Declaration is not needed.
1> Variable.
* 1: variable 'Variable' is unbound
%% Declare an assign at the same time
2> Variable = 'an atom'.
'an atom'
%% Valid variable names
3> Long_variable_name_In_here = 1.
1
4> AlphaNum3r1c = "a1".
"a1"
%% Non valid names
5> Non-Valid? = ups.
* 1: syntax error before: '?'
1> Count = 1.
1
2> Count = Count + 1.
** exception error: no match of right hand side value 2
3> NewCount = Count + 1.
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment