قالب وردپرس درنا توس
Home / Apple / Michael Tsai – Blog – Use Tuples As Easy Types In Swift

Michael Tsai – Blog – Use Tuples As Easy Types In Swift



John Sundell:

Although a tuple may have labels, you are always free to ignore them when creating an instance. This can help ensure that call pages look very nice and clean, for example when it comes to vector types, as coordinates.

[…]

Tuples can also be super helpful when checking if more values ​​are equal. While not complying with the [Equatable] protocol (or any protocol for that matter), the Swift defines the default library == tuples overloads that contain values ​​that are themselves equal.

[…]

It turns out that the argument list of any closure can actually be described by a tuple, and since - thanks to superior features - all functions are also closures, we can actually use a tuple to pass arguments to a function. All we have to do is get Swift to handle a function as a shutdown. To do so we could define a call feature that takes some function and uses its necessary arguments for it […]

John Sundell :

Tuples can't just be super helpful for grouping several related local variables in one, but can also be a great way to combine throwing expressions

Programming Swift Programming Language

Stay updated by subscribing to the RSS feed for this post.


Source link