File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -2214,12 +2214,17 @@ def Char.utf8Size (c : Char) : Nat :=
2214
2214
or `none`. In functional programming languages, this type is used to represent
2215
2215
the possibility of failure, or sometimes nullability.
2216
2216
2217
- For example, the function `HashMap.find ? : HashMap α β → α → Option β` looks up
2217
+ For example, the function `HashMap.get ? : HashMap α β → α → Option β` looks up
2218
2218
a specified key `a : α` inside the map. Because we do not know in advance
2219
2219
whether the key is actually in the map, the return type is `Option β`, where
2220
2220
`none` means the value was not in the map, and `some b` means that the value
2221
2221
was found and `b` is the value retrieved.
2222
2222
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
+
2223
2228
To extract a value from an `Option α`, we use pattern matching:
2224
2229
```
2225
2230
def map (f : α → β) (x : Option α) : Option β :=
You can’t perform that action at this time.
0 commit comments