Swift equivalent for MIN and MAX macros

后端 未结 5 1077
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 15:09

In C / Objective-C it is possible to find the minimum and maximum value between two numbers using MIN and MAX macros. Swift doesn\'t support macros and it seems that there a

5条回答
  •  感动是毒
    2020-12-02 15:27

    Try this.

        let numbers = [2, 3, 10, 9, 14, 6]  
        print("Max = \(numbers.maxElement()) Min = \(numbers.minElement())")
    

提交回复
热议问题