Skip to content

Commit 01c2c85

Browse files
authored
Merge pull request #14769 from moiseev/no-weird-overload
[stdlib] Remove the unnecessary compactMap overload
2 parents d991452 + 9d70574 commit 01c2c85

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

stdlib/public/core/StringRangeReplaceableCollection.swift.gyb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -574,41 +574,6 @@ extension Sequence {
574574
}
575575

576576
extension Collection {
577-
/// Returns an array containing the non-`nil` strings resulting from the given
578-
/// transformation on each element of this sequence.
579-
///
580-
/// Use this method to receive an array of non-optional strings when your
581-
/// transformation produces a `String?`.
582-
///
583-
/// In this example, note the difference in the result of using `map` and
584-
/// `compactMap` with a transformation that returns a `String?` value.
585-
///
586-
/// let errorLookup = [400: "Bad request",
587-
/// 403: "Forbidden",
588-
/// 404: "Not found"]
589-
///
590-
/// let errorCodes = [400, 407, 404]
591-
///
592-
/// let mapped: [String?] = errorCodes.map { code in errorLookup[code] }
593-
/// // ["Bad request", nil, "Not found"]
594-
///
595-
/// let compactMapped: [String] = errorCodes.compactMap { code in errorLookup[code] }
596-
/// // ["Bad request", "Not found"]
597-
///
598-
/// - Parameter transform: A closure that accepts an element of this
599-
/// sequence as its argument and returns a `String?`.
600-
/// - Returns: An array of the non-`nil` results of calling `transform`
601-
/// with each element of the sequence.
602-
///
603-
/// - Complexity: O(*m* + *n*), where *m* is the length of this sequence
604-
/// and *n* is the length of the result.
605-
@_inlineable // FIXME(sil-serialize-all)
606-
public func compactMap(
607-
_ transform: (Element) throws -> String?
608-
) rethrows -> [String] {
609-
return try _compactMap(transform)
610-
}
611-
612577
@available(swift, deprecated: 4.1, renamed: "compactMap(_:)",
613578
message: "Please use compactMap(_:) for the case where closure returns an optional value")
614579
@inline(__always)

0 commit comments

Comments
 (0)