New operators are declared at a global level using the operator
keyword, and are marked with the prefix
, infix
or postfix
modifiers:
- prefix operator +++
The following example defines a new custom infix operator called +-
, which belongs to the precedence group AdditionPrecedence
:
- infix operator +-: AdditionPrecedence