简体   繁体   中英

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!

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM