<div dir="ltr"><span style="font-size:14px"> [(1, 2)].map({ x, y in x + y }) // this</span><span style="font-size:14px"> line</span><span style="font-size:14px"> is correct</span><div><span style="font-size:14px"> [(1, 2)].map({ tuple in</span><span style="font-size:14px"> tuple.0</span><span style="font-size:14px"> + </span><span style="font-size:14px">tuple.1 </span><span style="font-size:14px">}) // this line should not accepted</span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">or</span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px"> [(1, 2)].map({ $0 + $1 }) // this</span><span style="font-size:14px"> line</span><span style="font-size:14px"> is correct</span><div><span style="font-size:14px"> [(1, 2)].map({ $0.0 + $0.1</span><span style="font-size:14px"> </span><span style="font-size:14px">}) // this line should not accepted</span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">it's because </span><span style="font-size:14px">`((Int, Int)) -> Int` always </span><span style="font-size:14px">flatten to </span><span style="font-size:14px">`(Int, Int) -> Int`</span></div></div><div><span style="font-size:14px">so, it should only accept the function with two arguments</span></div><div><span style="font-size:14px"><br></span></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-07 11:07 GMT+08:00 Stephen Celis <span dir="ltr"><<a href="mailto:stephen.celis@gmail.com" target="_blank">stephen.celis@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I like this a lot, but how do we solve for the function case?<br>
<br>
func add(_ x: Int, _ y: Int) -> Int {<br>
return x + y<br>
}<br>
[(1, 2)].map(add)<br>
<br>
Where does `map` with a function of `((Int, Int)) -> Int` fit in?<br>
<div><div class="h5"><br>
> On Jun 6, 2017, at 10:15 PM, Susan Cheng via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> Introduction<br>
><br>
><br>
> Because the painful of SE-0110, here is a proposal to clarify the tuple syntax.<br>
><br>
> Proposed solution<br>
><br>
> 1. single element tuple always be flattened<br>
><br>
> let tuple1: (((Int))) = 0 // TypeOf(tuple1) == Int<br>
><br>
> let tuple2: ((((Int))), Int) = (0, 0) // TypeOf(tuple2) == (Int, Int)<br>
><br>
> 2. function arguments list also consider as a tuple, which means the function that accept a single tuple should always be flattened.<br>
><br>
> let fn1: (Int, Int) -> Void = { _, _ in }<br>
><br>
> let fn2: ((Int, Int)) -> Void = { _, _ in } // always flattened<br>
><br>
> let fn3: (Int, Int) -> Void = { _ in } // not allowed, here are two arguments<br>
><br>
> let fn4: ((Int, Int)) -> Void = { _ in } // not allowed, here are two arguments<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
</blockquote></div><br></div>