mattbirchler
mattbirchler

Reputation: 13

Swift - How can I compare the values of a collection of variables?

I have 7 variables called averageMon, averageTue, averageWed, and so on, and I need to compare the value stored in each variable to see which holds the highest value. I've been looking around but haven't found a way to do this. I'm brand new to this, and I'm sure this is a simple question, but any help would be appreciated. Thanks!

Upvotes: 1

Views: 61

Answers (1)

Nico Ledwith
Nico Ledwith

Reputation: 28

If I understand correctly, just call the max function:

max(averageMon, averageTue, averageWed, averageThu, averageFri, averageSat, averageSun)

http://swift-ios.co/standard-functions-in-swift/

Upvotes: 1

Related Questions