Let's say we have a function that contains multiple parameters to build a person's basic information:
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")
If we don't want to provide all the parameters at once, we can transform it into a curring function:
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 ") )
We have decomposed the original function into a sequence of functions that accept a single argument.
Reference Link: http://justtesting.org/post/94325843216/what-is-currying-in-swift
How to convert a multi-parameter function in Swift into a curring function