Attention! Translated article might be found on my English blog.

2014年11月8日土曜日

MAX(), MIN()マクロのSwift版

Swiftではmax()およびmin()という関数があるようです。

/// Return the greatest argument passed
func max<T : Comparable>(x: T, y: T, z: T, rest: T...) -> T


/// Return the greater of `x` and `y`

func max<T : Comparable>(x: T, y: T) -> T

/// Return the lesser of `x` and `y`
func min<T : Comparable>(x: T, y: T) -> T


/// Return the least argument passed
func min<T : Comparable>(x: T, y: T, z: T, rest: T...) -> T