Skip to content

[4.1][stdlib] Remove the unnecessary compactMap overload #14779

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

Merged
merged 2 commits into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions stdlib/public/core/StringRangeReplaceableCollection.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -441,41 +441,6 @@ extension Sequence {
}

extension Collection {
/// Returns an array containing the non-`nil` strings resulting from the given
/// transformation on each element of this sequence.
///
/// Use this method to receive an array of non-optional strings when your
/// transformation produces a `String?`.
///
/// In this example, note the difference in the result of using `map` and
/// `compactMap` with a transformation that returns a `String?` value.
///
/// let errorLookup = [400: "Bad request",
/// 403: "Forbidden",
/// 404: "Not found"]
///
/// let errorCodes = [400, 407, 404]
///
/// let mapped: [String?] = errorCodes.map { code in errorLookup[code] }
/// // ["Bad request", nil, "Not found"]
///
/// let compactMapped: [String] = errorCodes.compactMap { code in errorLookup[code] }
/// // ["Bad request", "Not found"]
///
/// - Parameter transform: A closure that accepts an element of this
/// sequence as its argument and returns a `String?`.
/// - Returns: An array of the non-`nil` results of calling `transform`
/// with each element of the sequence.
///
/// - Complexity: O(*m* + *n*), where *m* is the length of this sequence
/// and *n* is the length of the result.
@_inlineable // FIXME(sil-serialize-all)
public func compactMap(
_ transform: (Element) throws -> String?
) rethrows -> [String] {
return try _compactMap(transform)
}

@available(swift, deprecated: 4.1, renamed: "compactMap(_:)",
message: "Please use compactMap(_:) for the case where closure returns an optional value")
@inline(__always)
Expand Down