Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterate docs typo #55055

Closed
RoyCCWang opened this issue Jul 6, 2024 · 0 comments · Fixed by #55139
Closed

iterate docs typo #55055

RoyCCWang opened this issue Jul 6, 2024 · 0 comments · Fixed by #55139
Labels
docs This change adds or pertains to documentation iteration Involves iteration or the iteration protocol

Comments

@RoyCCWang
Copy link

The docstring for iterate as shown in my REPL:

help?> iterate
search: iterate state Iterators bitrotate titlecase enumerate isinteractive @deprecate @generated intersect!

  iterate(iter [, state]) -> Union{Nothing, Tuple{Any, Any}}

  Advance the iterator to obtain the next element. If no elements remain, nothing should be returned. Otherwise, a 2-tuple of the next element and the new
  iteration state should be returned.

  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  iterate(s::AbstractString, i::Integer) -> Union{Tuple{<:AbstractChar, Int}, Nothing}

  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.

  See also getindex, checkbounds.

However, the following runs without error:

str = "1234"
out1 = iterate(str, 100)
out2 = iterate(str,-100)
@assert typeof(out1) <: Nothing
@assert typeof(out2) <: Nothing

I think this sentence in the docstring should be removed:

If i is out of bounds in s then a bounds error is raised.

My versioninfo()

Julia Version 1.11.0-rc1
Commit 3a35aec36d1 (2024-06-25 10:23 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 1700 Eight-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver1)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
@nsajko nsajko added the docs This change adds or pertains to documentation label Jul 7, 2024
@dkarrasch dkarrasch added the iteration Involves iteration or the iteration protocol label Jul 8, 2024
Octogonapus added a commit to Octogonapus/julia that referenced this issue Jul 15, 2024
…ring) docs.

Since at least v1.6 a bounds error has not been thrown if you iterate
outside the bounds of the string.
IanButterworth pushed a commit that referenced this issue Jul 18, 2024
- #55055: Remove incorrect BoundsError mention from iterate(string)
docs.
- #54686: Document the else keyword in the try/catch docs.

Closes #55055.
Closes #54686.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation iteration Involves iteration or the iteration protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants