From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- system/doc/reference_manual/patterns.xml | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 system/doc/reference_manual/patterns.xml (limited to 'system/doc/reference_manual/patterns.xml') diff --git a/system/doc/reference_manual/patterns.xml b/system/doc/reference_manual/patterns.xml new file mode 100644 index 0000000000..7289f14d73 --- /dev/null +++ b/system/doc/reference_manual/patterns.xml @@ -0,0 +1,59 @@ + + + + +
+ + 20032009 + Ericsson AB. All Rights Reserved. + + + The contents of this file are subject to the Erlang Public License, + Version 1.1, (the "License"); you may not use this file except in + compliance with the License. You should have received a copy of the + Erlang Public License along with this software. If not, it can be + retrieved online at http://www.erlang.org/. + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and limitations + under the License. + + + + Pattern Matching + + + + + patterns.xml +
+ +
+ Pattern Matching +

Variables are bound to values through the pattern matching mechanism. Pattern matching occurs when + evaluating a function call, case- receive- + try- expressions and match operator (=) expressions.

+

In a pattern matching, a left-hand side + pattern is matched + against a right-hand side + term. If + the matching succeeds, any unbound variables in the pattern + become bound. If the matching fails, a run-time error occurs.

+

Examples:

+
+1> X.
+** 1: variable 'X' is unbound **
+2> X = 2.
+2
+3> X + 1.
+3
+4> {X, Y} = {1, 2}.
+** exception error: no match of right hand side value {1,2}
+5> {X, Y} = {2, 3}.
+{2,3}
+6> Y.
+3
+
+
+ -- cgit v1.2.3