File tree Expand file tree Collapse file tree 1 file changed +11
-35
lines changed
Expand file tree Collapse file tree 1 file changed +11
-35
lines changed Original file line number Diff line number Diff line change 1919 * _ Regular Expressions_
2020 * [ Metaprogramming] ( #metaprogramming )
2121 * [ Testing] ( #testing )
22- * [ Suggested Alternatives] ( #suggested-alternatives )
2322 * [ Alternative Style Guides] ( #alternative-style-guides )
2423 * [ Tools] ( #tools )
2524* __ [ Getting Involved] ( #getting-involved ) __
@@ -351,6 +350,17 @@ Translations of the guide are available in the following languages:
351350 <sup >[[ link] ( #true-as-last-condition )] </sup >
352351
353352 ``` elixir
353+ # not preferred
354+ cond do
355+ 1 + 2 == 5 ->
356+ " Nope"
357+ 1 + 3 == 5 ->
358+ " Uh, uh"
359+ :else ->
360+ " OK"
361+ end
362+
363+ # preferred
354364 cond do
355365 1 + 2 == 5 ->
356366 " Nope"
@@ -1045,40 +1055,6 @@ _No guidelines for regular expressions have been added yet._
10451055 assert {:ok , expected} = actual_function (3 )
10461056 ```
10471057
1048- ### Suggested Alternatives
1049-
1050- Suggested alternatives are styles that haven't been seen much in the community
1051- yet but might provide some value.
1052-
1053- #### Cond
1054-
1055- * <a name =" atom-conditions " ></a >
1056- An atom can be used as a catch-all expression in a ` cond ` as it evaluates
1057- to a truthy value.
1058- Suggested atoms are ` :else ` or ` :otherwise `
1059- <sup >[[ link] ( #atom-conditions )] </sup >
1060-
1061- ``` elixir
1062- cond do
1063- 1 + 2 == 5 ->
1064- " Nope"
1065- 1 + 3 == 5 ->
1066- " Uh, uh"
1067- :else ->
1068- " OK"
1069- end
1070-
1071- # is the same as
1072- cond do
1073- 1 + 2 == 5 ->
1074- " Nope"
1075- 1 + 3 == 5 ->
1076- " Uh, uh"
1077- true ->
1078- " OK"
1079- end
1080- ```
1081-
10821058### Alternative Style Guides
10831059
10841060* [ Aleksei Magusev's Elixir Style Guide] ( https://github.com/lexmag/elixir-style-guide#readme )
You can’t perform that action at this time.
0 commit comments