summaryrefslogtreecommitdiffhomepage
path: root/erlang.html.markdown
diff options
context:
space:
mode:
authorven <vendethiel@hotmail.fr>2015-10-03 18:21:51 +0200
committerven <vendethiel@hotmail.fr>2015-10-03 18:21:51 +0200
commit907f4515ca8a80679213d5c0268453fdec3572e1 (patch)
treefecef83a8fe613a4bae44c2d09822302db24674d /erlang.html.markdown
parent59eaefac54e0551e9c1000e4f5a7fe9edc814993 (diff)
parent2e05ec8d955b62fef844bd460f5bb455e351d1d0 (diff)
Merge pull request #1280 from edholland/fix-1139
Add clarification on bind / match with = op in erlang. Fixes #1139
Diffstat (limited to 'erlang.html.markdown')
-rw-r--r--erlang.html.markdown9
1 files changed, 6 insertions, 3 deletions
diff --git a/erlang.html.markdown b/erlang.html.markdown
index 8b67a76a..d0af7f05 100644
--- a/erlang.html.markdown
+++ b/erlang.html.markdown
@@ -25,6 +25,7 @@ filename: learnerlang.erl
%% 1. Variables and pattern matching.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% In Erlang new variables are bound with an `=` statement.
Num = 42. % All variable names must start with an uppercase letter.
% Erlang has single-assignment variables; if you try to assign a different
@@ -32,9 +33,11 @@ Num = 42. % All variable names must start with an uppercase letter.
Num = 43. % ** exception error: no match of right hand side value 43
% In most languages, `=` denotes an assignment statement. In Erlang, however,
-% `=` denotes a pattern-matching operation. `Lhs = Rhs` really means this:
-% evaluate the right side (`Rhs`), and then match the result against the
-% pattern on the left side (`Lhs`).
+% `=` denotes a pattern-matching operation. When an empty variable is used on the
+% left hand side of the `=` operator to is bound (assigned), but when a bound
+% varaible is used on the left hand side the following behaviour is observed.
+% `Lhs = Rhs` really means this: evaluate the right side (`Rhs`), and then
+% match the result against the pattern on the left side (`Lhs`).
Num = 7 * 6.
% Floating-point number.