[Solved] How to collect the return value of a function (Swift 3)


You can return like below,

let userName = "Jake" //Global variable of the class
let userInfo = test() //Jake

func test() -> String { //single - element tuple will don't have label for return.

   return self.userName
}

If you like to return with labels then you need tow or more return values like below,

   func test() -> (name:String,age:Int) {        
       return (self.userName,125)
    }

And access specific values by test().name

0

solved How to collect the return value of a function (Swift 3)