[swift-evolution] Pre-proposal: Convert reference params to tuples
cocoadev at charlessoft.com
Mon Jan 11 20:18:31 CST 2016
> On Jan 11, 2016, at 8:05 PM, Philippe Hausler <phausler at apple.com> wrote:
> Cases like this are kinda cagey because you have to keep track of which string is which; is it the foo result string or the bar result string at .0 versus .1? I find myself always favoring struct or inout for clarity/safety.
In the case where the original API distinguishes between the two (-fooAndReturnBar:), you can return a named (or partially-named) tuple, like in one my later examples. In this case, the original API doesn’t have this information either, so we can’t translate it into something better (although I don’t believe this pattern is very common, so that helps).
In the more common case where you have something like fooWithBar: you can add a “bar:” label on the second parameter.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution