假设我们有一个含有多个参数的函数,用于构建一个人的基本信息:
func buildInfoWithName(name: String,#age: Int,#gender: String,#address: String,#phone: String) -> String { return "My name is " + name + ",I'm a " + gender + ",I live in " + address + ",my phone number is " + phone } let mike = buildInfoWithName("Mike",age: 20,gender: "boy",address: "Tokyo Japan",phone: "12345678")
func buildInfoWithName(name: String)(age: Int)(gender: String)(address: String)(phone: String) -> String { return "My name is " + name + ",I'm a " + gender + ",I live in " + address + ",my phone number is " + phone } let benson = buildInfoWithName("Benson")(age: 24)(gender: "boy")(address: "Chengdu Sichuan")(phone: "87654321")
参考链接:http://justtesting.org/post/94325843216/what-is-currying-in-swift