Skip to content

Conversation

Kyle-Ye
Copy link
Contributor

@Kyle-Ye Kyle-Ye commented Sep 29, 2025

Summary

This PR fixes a documentation issue reported in the Swift forums:
https://forums.swift.org/t/error-in-swift-documentation/82417

Details

Motivation

The previous text could cause confusion for readers and does not reflect the correct usage/behavior.

This change aligns the documentation with the actual standard library implementation.

Verification

  • Verified the fix locally by running the example code.
swift repl
Welcome to Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2).
Type :help for assistance.
  1> var letters = Array("ABCdeFGhijkLMNOp")
  2. let uppercaseRanges = letters.indices(where: { $0.isUppercase })
  3. let rangeOfUppercase = letters.moveSubranges(uppercaseRanges, to: 10)
letters: [String.Element] = 16 values {
  [0] = "d"
  [1] = "e"
  [2] = "h"
  [3] = "i"
  [4] = "j"
  [5] = "A"
  [6] = "B"
  [7] = "C"
  [8] = "F"
  [9] = "G"
  [10] = "L"
  [11] = "M"
  [12] = "N"
  [13] = "O"
  [14] = "k"
  [15] = "p"
}
uppercaseRanges: RangeSet<[String.Element].Index> = {
  _ranges = {
    _storage = 3 values {
      [0] = 0..<3
      [1] = 5..<7
      [2] = 11..<15
    }
  }
}
rangeOfUppercase: Range<[String.Element].Index> = 5..<14
  4> letters
$R0: [String.Element] = 16 values {
  [0] = "d"
  [1] = "e"
  [2] = "h"
  [3] = "i"
  [4] = "j"
  [5] = "A"
  [6] = "B"
  [7] = "C"
  [8] = "F"
  [9] = "G"
  [10] = "L"
  [11] = "M"
  [12] = "N"
  [13] = "O"
  [14] = "k"
  [15] = "p"
}

@Kyle-Ye Kyle-Ye requested a review from a team as a code owner September 29, 2025 11:21
@Kyle-Ye
Copy link
Contributor Author

Kyle-Ye commented Sep 29, 2025

@swift-ci please test

@Kyle-Ye Kyle-Ye requested review from heckj and amartini51 September 29, 2025 11:25
@Azoy Azoy merged commit 7502c76 into main Sep 30, 2025
5 checks passed
@Azoy Azoy deleted the fix/move_subranges_documentation branch September 30, 2025 16:18
@Azoy
Copy link
Contributor

Azoy commented Sep 30, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants