[swift-evolution] Implicit Optionals for Tuples & Tuples as Function Parameter

Nevin Brackett-Rozinsky nevin.brackettrozinsky at gmail.com
Fri Nov 11 15:37:26 CST 2016


I’ll mention this here since it’s related to tuples and optionals. Starting
with this setup:

var x, y: Int?
func f() -> (Int, Int) { return (0, 1) }

This fails to compile:

(x, y) = f()  // Error: Cannot express tuple conversion '(Int, Int)' to
'(Int?, Int?)'

But this works fine:

func g() -> Int { return 2 }
(x, y) = (g(), g())

What is going on, why does the first one fail, and is this a bug or does it
need a proposal to fix?

Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161111/9f63a7e0/attachment.html>


More information about the swift-evolution mailing list