ybakos
ybakos

Reputation: 8630

Using Swift tuples as an alternative to multiple assignment

Is there any performance impact or best practice conflict regarding readablity if I do this in Swift:

var (a, b, c, d) = (0, 0, 0, 0)

Instead of this:

var a = 0, b = 0, c = 0, d = 0

Upvotes: 3

Views: 571

Answers (1)

zaph
zaph

Reputation: 112873

The best practice is to be as clear (to other programmers) as possible with your code.

To be concerned about optimization at the level is just crazy. Donald Knuth: "Premature optimization is the root of all evil (or at least most of it) in programming.".

Upvotes: 3

Related Questions