Advertisement
applehelpwriter

Swift func with variable number of parameters

Jun 4th, 2014
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //swift
  2.  
  3. //variable number of parameters
  4.  
  5. func sumOf(numbers: Int...) -> Int {
  6.     var sum = 0
  7.     for number in numbers {
  8.     sum += number
  9.     }
  10.     return sum
  11. }
  12.  
  13. sumOf(1,2,3,4,5,6,7,8,9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement