@@ -502,27 +502,23 @@ public struct IndexingIterator<
502
502
/// ================================
503
503
///
504
504
/// You can access a slice of a collection through its ranged subscript or by
505
- /// calling methods like `prefix(_ :)` or `suffix(from :)`. A slice of a
505
+ /// calling methods like `prefix(while :)` or `suffix(_ :)`. A slice of a
506
506
/// collection can contain zero or more of the original collection's elements
507
507
/// and shares the original collection's semantics.
508
508
///
509
509
/// The following example creates a `firstWord` constant by using the
510
- /// `prefix(_ :)` method to get a slice of the `text` string.
510
+ /// `prefix(where :)` method to get a slice of the `text` string.
511
511
///
512
- /// let firstWord = text.prefix(7 )
512
+ /// let firstWord = text.prefix(while: { $0 != " " } )
513
513
/// print(firstWord)
514
514
/// // Prints "Buffalo"
515
515
///
516
- /// You can retrieve the same slice using other methods, such as finding the
517
- /// terminating index, and the using the string's ranged subscript, or by
518
- /// using the `prefix(upTo:)` method, which takes an index as its parameter.
516
+ /// You can retrieve the same slice using the string's ranged subscript, which
517
+ /// takes a range expression.
519
518
///
520
519
/// if let firstSpace = text.index(of: " ") {
521
520
/// print(text[..<firstSpace]
522
521
/// // Prints "Buffalo"
523
- ///
524
- /// print(text.prefix(upTo: firstSpace))
525
- /// // Prints "Buffalo"
526
522
/// }
527
523
///
528
524
/// The retrieved slice of `text` is equivalent in each of these cases.
0 commit comments