What this line means in Swift?

前端 未结 3 1983
别跟我提以往
别跟我提以往 2021-01-24 11:10

I\'m now reading Swift 3 book and found this line there:

func sumOf(numbers: Int...) -> Int {

}

and there are just this description:

<
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 11:33

    Example for using function with varidic arguments

    func log(args: AnyObject ...) {
      var text = ""
      for arg in args {
        text += " \(arg)"
      }
      print("\(text)")
    }
    

    log("Arg1", "Arg2")

    log("Arg1", "Arg2", "Arg3")

提交回复
热议问题