[swift-evolution] Optional Argument Chaining
Xiang Deng
dengxiang2010 at gmail.com
Wed Dec 13 00:54:04 CST 2017
Hi all,
We probably don't need additional syntax to achieve this. I just wrote a library which allows you to `(pass?.aLongOptionalChaining()?.to ?< aFunctionTakingNonOptionalValues(:))?.ThenDoSomethingElse()` with `?>` operator.
The multiple parameters example:
(john.address, alice.address, 2.0) ?> getPostageEstimate(source:destination:weight:)
> // Equivalent to
> john.address.flatMap { freshVar1 in
> alice.address.flatMap { freshVar2 in
> getPostageEstimate(source: freshVar1, destination: freshVar2, weight: 2.0)
> }
> }
See more about the library: https://github.com/ddddxxx/ChainingFunction <https://github.com/ddddxxx/ChainingFunction>
--
Xander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171213/caef9047/attachment.html>
More information about the swift-evolution
mailing list