From 8cd37fc2937d32d9f2457bcb35770b885cbd35b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Gim=C3=A9nez?= Date: Wed, 3 Jan 2018 21:43:43 -0300 Subject: [PATCH 1/3] Add Case control flow structre and remove css class --- elixir.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/elixir.md b/elixir.md index d9ed705a5..f67592614 100644 --- a/elixir.md +++ b/elixir.md @@ -105,7 +105,6 @@ Pattern matching works in function parameters too. Control flow ------------ -{: .-three-column} ### If @@ -116,6 +115,18 @@ else "This will" end ``` +### Case + +```elixir +case {1, 2, 3} do + {4, 5, 6} -> + "This clause won't match" + {1, x, 3} -> + "This clause will match and bind x to 2 in this clause" + _ -> + "This clause would match any value" +end +``` ### Cond From f81377fb28ebd3c92a4a4fcbb3ae9e72070b443e Mon Sep 17 00:00:00 2001 From: Gustavo Gimenez Date: Wed, 3 Jan 2018 22:12:25 -0300 Subject: [PATCH 2/3] fix concat result --- elixir.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir.md b/elixir.md index f67592614..273def3cd 100644 --- a/elixir.md +++ b/elixir.md @@ -477,7 +477,7 @@ list |> any?() # → true ``` ```elixir -list |> concat([:d]) # → [:d] +list |> concat([:d]) # → [:a, :b, :c, :d] ``` Also, consider streams instead. From ba6239e7e9e70f7815f0a5ab346b195cb1df29d1 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 17 Mar 2018 13:25:56 +0800 Subject: [PATCH 3/3] elixir: shorten some sentences --- elixir.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elixir.md b/elixir.md index 273def3cd..35b493479 100644 --- a/elixir.md +++ b/elixir.md @@ -105,6 +105,7 @@ Pattern matching works in function parameters too. Control flow ------------ +{: .-three-column} ### If @@ -122,9 +123,9 @@ case {1, 2, 3} do {4, 5, 6} -> "This clause won't match" {1, x, 3} -> - "This clause will match and bind x to 2 in this clause" + "This will match and bind x to 2" _ -> - "This clause would match any value" + "This will match any value" end ```