[swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

Gwendal Roué gwendal.roue at gmail.com
Thu Nov 16 04:13:58 CST 2017


> Le 16 nov. 2017 à 11:06, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> a écrit :
> 
>> On Nov 15, 2017, at 4:36 PM, Greg Parker via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> "compactMap" is okay if "compact" is added. Is "compact" a common enough operation in practice to pull its own weight?
> 
> Lines containing code like `flatMap { $0 }`—which could be compacting optionals or flattening nested sequences—appear 89 times in the source compatibility suite. (I happen to have it on my hard drive right now.)
> 
> My main concern about adding a compacting method is…well, am I missing a better implementation than the slightly gross one I cooked up in a playground just now?
> 
> 	protocol _OptionalProtocol {
> 	    associatedtype _Wrapped
> 	    var _optional: _Wrapped? { get }
> 	}


Welcome to the club :-) https://github.com/search?q=OptionalProtocol+language%3Aswift&type=Code&utf8=✓

Gwendal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171116/c7c298b1/attachment.html>


More information about the swift-evolution mailing list