Skip to content

Commit 4af69dc

Browse files
committed
Add note about withDefault overuse
1 parent c1526f9 commit 4af69dc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Maybe.elm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ value. This comes in handy when paired with functions like
5050
5151
withDefault "unknown" (Dict.get "Tom" Dict.empty) -- "unknown"
5252
53+
**Note:** This can be overused! Many cases are better handled by a `case`
54+
expression. And if you end up using `withDefault` a lot, it can be a good sign
55+
that a [custom type][ct] will clean your code up quite a bit!
56+
57+
[ct]: https://guide.elm-lang.org/types/custom_types.html
5358
-}
5459
withDefault : a -> Maybe a -> a
5560
withDefault default maybe =

0 commit comments

Comments
 (0)