swift向方法传数组参数的语法
总是记不住向方法中传数组参数的语法,所以记录一下。
func calculateStatistics(scores:[Int]) -> (min:Int,max:Int,sum:Int) { var min = scores[0] var max = scores[0] var sum = 0 for score in scores { if score>max { max=score } else if score<min{ min=score } sum += score } return (min,max,sum) } let a=calculateStatistics([5,3,100,3,9]) print(a.min) print(a.sum) print(a.0)
最主要的是这句:func calculateStatistics(scores:[Int]) -> (min:Int,max:Int,sum:Int) {}
** Then I looked up at the sky and saw the sun **
posted on 2016-05-24 16:24 chenyangsocool 阅读(453) 评论(0) 编辑 收藏 举报