// 定义函数,返回值类型是String func getUser(name: String, age:Int) -> (String) { return "name:" + name + " age:" + "\(age)" } // 调用getUser函数 let user = getUser(name: "jzh", age: 35) print("user:\(user)")
// 调用getUser函数 let user = getUser(name: "jzh", age: 35) print("user:\(user)") // 定义一个可以返回多个值的函数(返回两个值:name和age) func getUserInfo() -> (name:String, age:Int) { return ("jzh", 35) } print(getUserInfo()) print("name: \(getUserInfo().name)") print("age: \(getUserInfo().age)")