Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

Defining a custom operator

Firstly, we need to tell Swift about how our operator looks:

prefixoperator-><- 
This declaration must take place at file scope, meaning outside of any class, func, or other declarations.

So what does prefix mean in this context? There are three categories of operator, defined according to their position with regards to their operands: