Skip to content

Commit

Permalink
doc: remove reference to HashMap.find? from Option docstring (#4782)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoFX authored Jul 21, 2024
1 parent 8ceb24a commit bdfaa00
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Init/Prelude.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2214,12 +2214,17 @@ def Char.utf8Size (c : Char) : Nat :=
or `none`. In functional programming languages, this type is used to represent
the possibility of failure, or sometimes nullability.
For example, the function `HashMap.find? : HashMap α β → α → Option β` looks up
For example, the function `HashMap.get? : HashMap α β → α → Option β` looks up
a specified key `a : α` inside the map. Because we do not know in advance
whether the key is actually in the map, the return type is `Option β`, where
`none` means the value was not in the map, and `some b` means that the value
was found and `b` is the value retrieved.
The `xs[i]` syntax, which is used to index into collections, has a variant
`xs[i]?` that returns an optional value depending on whether the given index
is valid. For example, if `m : HashMap α β` and `a : α`, then `m[a]?` is
equivalent to `HashMap.get? m a`.
To extract a value from an `Option α`, we use pattern matching:
```
def map (f : α → β) (x : Option α) : Option β :=
Expand Down

0 comments on commit bdfaa00

Please sign in to comment.