Skip to content

Commit 2d6efaf

Browse files
author
Dave Abrahams
committed
[stdlib] constistently name param to map/flatMap
1 parent 123fbaa commit 2d6efaf

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

stdlib/public/core/Optional.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ public enum Optional<Wrapped> : NilLiteralConvertible {
153153
/// print(noSquare)
154154
/// // Prints "nil"
155155
///
156-
/// - Parameter f: A closure that takes the unwrapped value of the instance.
156+
/// - Parameter transform: A closure that takes the unwrapped value
157+
/// of the instance.
157158
/// - Returns: The result of the given closure. If this instance is `nil`,
158159
/// returns `nil`.
159-
public func map<U>(_ f: @noescape (Wrapped) throws -> U) rethrows -> U? {
160+
public func map<U>(
161+
_ transform: @noescape (Wrapped) throws -> U
162+
) rethrows -> U? {
160163
switch self {
161164
case .some(let y):
162-
return .some(try f(y))
165+
return .some(try transform(y))
163166
case .none:
164167
return .none
165168
}
@@ -180,13 +183,16 @@ public enum Optional<Wrapped> : NilLiteralConvertible {
180183
/// print(nonOverflowingSquare)
181184
/// // Prints "Optional(1746)"
182185
///
183-
/// - Parameter f: A closure that takes the unwrapped value of the instance.
186+
/// - Parameter transform: A closure that takes the unwrapped value
187+
/// of the instance.
184188
/// - Returns: The result of the given closure. If this instance is `nil`,
185189
/// returns `nil`.
186-
public func flatMap<U>(_ f: @noescape (Wrapped) throws -> U?) rethrows -> U? {
190+
public func flatMap<U>(
191+
_ transform: @noescape (Wrapped) throws -> U?
192+
) rethrows -> U? {
187193
switch self {
188194
case .some(let y):
189-
return try f(y)
195+
return try transform(y)
190196
case .none:
191197
return .none
192198
}

test/Prototypes/CollectionTransformers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ internal class _CollectionTransformerStep<PipelineInputElement_, OutputElement_>
853853
typealias PipelineInputElement = PipelineInputElement_
854854
typealias OutputElement = OutputElement_
855855

856-
func map<U>(_ elementTransform: (OutputElement) -> U)
856+
func map<U>(_ transform: (OutputElement) -> U)
857857
-> _CollectionTransformerStep<PipelineInputElement, U> {
858858

859859
fatalError("abstract method")

0 commit comments

Comments
 (0)