[swift-users] another issue with tuples
Zhao Xin
owenzx at gmail.com
Wed Jul 6 01:05:58 CDT 2016
Tuple is not designed to be used as commonly as classes and structs.
NOTE
> Tuples are useful for temporary groups of related values. They are not
> suited to the creation of complex data structures. If your data structure
> is likely to persist beyond a temporary scope, model it as a class or
> structure, rather than as a tuple. For more information, see Classes and
> Structures.
quoting from:
> https://developer.apple.com/library/prerelease/content/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html
>
If you looking up in the documents, there is no struct nor class called
Tuple. The normal using on tuple in my option is to returning multiple
values in a function, or switch-case matching.
So you are right, tuple is not well-formed. But it is designed to be used
only temporarily. Please feel free to file another bug.
Zhaoxin
On Wed, Jul 6, 2016 at 1:48 PM, Aaron Bohannon via swift-users <
swift-users at swift.org> wrote:
> Yesterday, it was pointed out that a variable name referring to a tuple
> cannot be used as a pattern. I have noticed another sort of inconsistency
> in how tuples are treated when they are referenced by name:
>
> func f() -> Int { return 5 }
>
> let t = ("a", f)
>
> let _: (String, () throws -> Int) = t // type error
> let _: (String, () throws -> Int) = (t.0, t.1) // OK
>
> This situation leads to a different sort of type error; however, the error
> seems equally unwarranted. I can't see any good reason for a well-typed
> program to become ill-typed when `(t.0, t.1)` is replaced with `t`
> (assuming `t` is a pair).
>
> Should I file a separate bug for the specific example above?
>
> - Aaron
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160706/e661f23f/attachment.html>
More information about the swift-users
mailing list