Skip to content

Commit

Permalink
Clean up some docs issues (#55139)
Browse files Browse the repository at this point in the history
- #55055: Remove incorrect BoundsError mention from iterate(string)
docs.
- #54686: Document the else keyword in the try/catch docs.

Closes #55055.
Closes #54686.
  • Loading branch information
Octogonapus authored Jul 18, 2024
1 parent d4362e4 commit 0e6d797
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 14 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,17 @@ exception object to the given variable within the `catch` block.
The power of the `try`/`catch` construct lies in the ability to unwind a deeply
nested computation immediately to a much higher level in the stack of calling functions.
A `try/catch` block can also have an `else` clause that executes only if no exception occurred:
```julia
try
a_dangerous_operation()
catch
@warn "The operation failed."
else
@info "The operation succeeded."
end
```
A `try` or `try`/`catch` block can also have a [`finally`](@ref) clause that executes
at the end, regardless of whether an exception occurred. For example, this can be
used to guarantee that an opened file is closed:
Expand All @@ -1064,6 +1075,9 @@ finally
end
```
(`finally` can also be used without a `catch` block.)
!!! compat "Julia 1.8"
Else clauses require at least Julia 1.8.
"""
kw"try", kw"catch"

Expand Down
5 changes: 2 additions & 3 deletions base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ Stacktrace:
Return a tuple of the character in `s` at index `i` with the index of the start
of the following character in `s`. This is the key method that allows strings to
be iterated, yielding a sequences of characters. If `i` is out of bounds in `s`
then a bounds error is raised. The `iterate` function, as part of the iteration
protocol may assume that `i` is the start of a character in `s`.
be iterated, yielding a sequences of characters. The `iterate` function, as part
of the iteration protocol may assume that `i` is the start of a character in `s`.
See also [`getindex`](@ref), [`checkbounds`](@ref).
"""
Expand Down

0 comments on commit 0e6d797

Please sign in to comment.