We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ba614e commit cc1cc97Copy full SHA for cc1cc97
language/Pattern-Matching.md
@@ -176,6 +176,29 @@ compare _ _ = EQ
176
177
(The name `otherwise` is a synonym for `true` commonly used in guards.)
178
179
+Guards may also be used within `case` expressions, which allow for inline expressions. For example, these are equivalent:
180
+
181
+```purs
182
+fb :: Int -> Effect Unit
183
+fb = log <<< case _ of
184
+ n
185
+ | 0 == mod n 15 -> "FizzBuzz"
186
+ | 0 == mod n 3 -> "Fizz"
187
+ | 0 == mod n 5 -> "Buzz"
188
+ | otherwise -> show n
189
+```
190
191
192
193
+fb n = log x
194
+ where
195
+ x
196
+ | 0 == mod n 15 = "FizzBuzz"
197
+ | 0 == mod n 3 = "Fizz"
198
+ | 0 == mod n 5 = "Buzz"
199
+ | otherwise = show n
200
201
202
Pattern Guards
203
--------------
204
0 commit comments