Skip to content

Commit 3380d99

Browse files
committed
doc: remove reference to HashMap.find? from Option docstring
1 parent c1df756 commit 3380d99

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Init/Prelude.lean

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,12 +2214,17 @@ def Char.utf8Size (c : Char) : Nat :=
22142214
or `none`. In functional programming languages, this type is used to represent
22152215
the possibility of failure, or sometimes nullability.
22162216
2217-
For example, the function `HashMap.find? : HashMap α β → α → Option β` looks up
2217+
For example, the function `HashMap.get? : HashMap α β → α → Option β` looks up
22182218
a specified key `a : α` inside the map. Because we do not know in advance
22192219
whether the key is actually in the map, the return type is `Option β`, where
22202220
`none` means the value was not in the map, and `some b` means that the value
22212221
was found and `b` is the value retrieved.
22222222
2223+
The `xs[i]` syntax, which is used to index into collections, has a variant
2224+
`xs[i]?` that returns an optional value depending on whether the given index
2225+
is valid. For example, if `m : HashMap α β` and `a : α`, then `m[a]?` is
2226+
equivalent to `HashMap.get? m a`.
2227+
22232228
To extract a value from an `Option α`, we use pattern matching:
22242229
```
22252230
def map (f : α → β) (x : Option α) : Option β :=

0 commit comments

Comments
 (0)