[stdlib] Rename index(...) methods to firstIndex(...)

A la SE-204.
This commit is contained in:
Nate Cook
2017-10-19 11:05:48 -05:00
parent 67852ed460
commit 58933d88c5
45 changed files with 200 additions and 175 deletions

View File

@@ -258,9 +258,9 @@ extension String : StringProtocol, RangeReplaceableCollection {
/// For example, this code finds the first letter after the first space:
///
/// let str = "Greetings, friend! How are you?"
/// let firstSpace = str.index(of: " ") ?? str.endIndex
/// let firstSpace = str.firstIndex(of: " ") ?? str.endIndex
/// let substr = str[firstSpace...]
/// if let nextCapital = substr.index(where: { $0 >= "A" && $0 <= "Z" }) {
/// if let nextCapital = substr.firstIndex(where: { $0 >= "A" && $0 <= "Z" }) {
/// print("Capital after a space: \(str[nextCapital])")
/// }
/// // Prints "Capital after a space: H"
@@ -436,7 +436,7 @@ extension String {
/// removes the hyphen from the middle of a string.
///
/// var nonempty = "non-empty"
/// if let i = nonempty.index(of: "-") {
/// if let i = nonempty.firstIndex(of: "-") {
/// nonempty.remove(at: i)
/// }
/// print(nonempty)