, reduce(), , , , , .
Think of operators as functions / closures, and you'll see why this is possible in Swift. Actually, operators are similar to functions - they are called closures.
Also think about how you can add new operators - you define a function with the name of the operator, which takes a number of parameters equal to the value of the operator.
Thus, the following is syntactically correct and provides the expected result ( 6):
[1,2,3].reduce(0, combine: +)
source
share