> Le 16 nov. 2017 à 11:06, Brent Royal-Gordon via swift-evolution 
> <swift-evolution@swift.org> a écrit :
> 
>> On Nov 15, 2017, at 4:36 PM, Greg Parker via swift-evolution 
>> <swift-evolution@swift.org <mailto:swift-evolution@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

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to