summaryrefslogtreecommitdiffhomepage
path: root/elixir.html.markdown
diff options
context:
space:
mode:
authorChris Zimmerman <chris@chriszimmerman.net>2018-10-08 12:17:24 -0400
committerChris Zimmerman <chris@chriszimmerman.net>2018-10-08 12:17:24 -0400
commitb230fbd52f2f1e657fd5ca384f88b0f1959d5809 (patch)
tree8ff43d1064cd08f6bf79cb928e25dddd56eff03e /elixir.html.markdown
parent215d688c0616f5023cab98b6b1ff9735581f03ec (diff)
Adds clarification for functions with multiple clauses.
Diffstat (limited to 'elixir.html.markdown')
-rw-r--r--elixir.html.markdown6
1 files changed, 5 insertions, 1 deletions
diff --git a/elixir.html.markdown b/elixir.html.markdown
index a74baa38..e82509e7 100644
--- a/elixir.html.markdown
+++ b/elixir.html.markdown
@@ -287,7 +287,11 @@ end
PrivateMath.sum(1, 2) #=> 3
# PrivateMath.do_sum(1, 2) #=> ** (UndefinedFunctionError)
-# Function declarations also support guards and multiple clauses:
+# Function declarations also support guards and multiple clauses.
+# When a function with multiple clauses is called, the first function
+# that satisfies the clause will be invoked.
+# Example: invoking area({:circle, 3}) will call the second area
+# function defined below, not the first:
defmodule Geometry do
def area({:rectangle, w, h}) do
w * h