Swift返回值
示例
函数可以通过在参数列表后指定类型来返回值。
func findHypotenuse(a: Double, b: Double) -> Double
{
return sqrt((a * a) + (b * b))
}
let c = findHypotenuse(3, b: 5)
//c=5.830951894845301函数也可以使用元组返回多个值。
func maths(number: Int) -> (times2: Int, times3: Int)
{
let two = number * 2
let three = number * 3
return (two, three)
}
let resultTuple = maths(5)
//resultTuple=(10,15)
热门推荐
10 亲人提车祝福语简短
11 送同学的简短祝福语
12 新婚简短的祝福语大全
13 春节祝福语大全简短搞笑
14 订婚祝福语简短诗句
15 拿到驾照的祝福语简短
16 元旦祝福语的英文简短
17 66红包祝福语简短的
18 生日祝福语简短致表哥