Infix syntax is a kind of OC Ritter, which is to add an explanatory word to the arguments of the function, so that the meaning of the parameter is understood when the call is made.
Like what:
-(void) Processdatawithparamaa: (NSString *) Paramaa paramab: (NSString *) paramab{}
When called:
[Self Processdatawithparamaa:@ "A" paramab:@ "B"];
But you find that, this infix syntax is the premise that you must be in the first name of the function, write a with what the name of a parameter, or the first parameter is not infix.
It does make the call look very pleasing to the eye, [xxxxxxwithparamaa:@ "A" paramab:@ "B"] parameters seem very consistent ah, praise.
So let's go back to Swift, if we declare a function like this
Func ProcessData2 (paramaa:string,paramab:string) {}
But his call to learn OC's infix, omitted the first parameter, then who will tell me the first parameter what meaning?
ProcessData2 ("a""b")
As an obsessive compulsive disorder, I can't bear it.
If the language is developed in order for us to adapt to OC's function naming habits (that is, the name of the letter to add a withxxx,xxx is the first parameter infix)
Then I must declare this:
Func Processdata2withparamaa (paramaa:string,paramab:string) {}
Crouching trough, what a ghost!!
And then call it? There is a wood in the outside of the brackets. There's no sense of paramaa inside.
Processdata2withparamaa ("a""b")
The OC call function is like this [self processdatawithparamaa:@ "A" paramab:@ "B"]
Both sides are in brackets.
This elegance your swift braces don't learn.
Fortunately, the development of the swift Chris Lattner man, and think of some developers do not like to call the time with what feather infix, so want to add an underscore to omit infix method:
Func processData3 (Paramaa:string,_ paramab:string) {}
In this way, when the call will no longer need to write parameters, mother no longer worry about me fan obsessive disorder:
ProcessData3 ("a""b")
Then, Yi? Where does it seem to be wrong? The first Paramaa actually become dispensable (in fact, has always been dispensable), meaning that it can be written like this
Func ProcessData3 (_ Paramaa:string,_ paramab:string) {}
Compilation is possible, but the compiler will prompt you, this is not a standard notation.
This is why ah ...
Leave me a way.
Swift's syntax for an obsessive-compulsive disorder under swift spat: infix grammar