Custom operators can contain only these characters:
/=-+ *% < >! & | ^. ~
Operator Location:
The predecessor operator prefix the intermediate operator infix the post operator Postfix
Operator additional configuration
binding associativity desirable range of values left,right and none priority precedence desirable value range0~255system built-in operator combined with properties and priority exponentiation (no combination, priority)<<bitwise Left SHIFT (Bitwise)>>Bitwise Right SHIFT (Bitwise shift) multiplication correlation (left-associative, priority-level)*Multiply/except%Seeking Redundancy&*multiplication, ignoring overflow (Multiply, ignoring overflow)&/Division, ignoring overflow (Divide, ignoring overflow)&%redundancy, ignoring overflow (remainder, ignoring overflow)&bit-to (Bitwise and) plus subtraction (left-associative, priority-only)+Plus-minus&+Add with overflow&-Subtract with overflow|Bitwise or (Bitwise or)^Bitwise XOR (Bitwise XOR) Range (no combination, priority135): Semi-closed domain half-closed Range ... Full-closed Value Closed range type conversion (no combination, priority the) istype checks (type check) astype conversions (type cast)<=less than or equal>Greater than>=greater than or equal==equals!=Unequal===constant equals!==not identical~=Pattern matching (pattern match) Hop (conjunctive) (left-associative, priority -)&&logical AND (Logical and) disjunction (disjunctive) (left associative, priority the)||logical OR (Logical or) ternary condition (ternary Conditional) (right-associative, priority -)?: Ternary conditional ternary conditional Assignment (Assignment) (right-associative, priority -)=Assign Value (Assign)*=Multiply and assign/=Divide and assign%=Remainder and assign+=Add and assign-=Subtract and assign<<=Left bit shift and assign=Right bit shift and assign&=Bitwise and and assign^=Bitwise XOR and assign|=Bitwise OR and assign&&=Logical and and assign|| = Logical OR and assign
Example
//Front: Returns 2 of the n-th squarePrefixoperator^{}prefix func^ (varvector:double)Double {returnPow2, Vector)} println (^5)//32.0//Back : Returns 2-Time SquarePostfixoperator^{}postfix func^ (varVector:int)Int {returnVector *Vector}println (5^)// -//Middle: Calculates N's M-time, left-associative, priority 255Infixoperator^^ {associativity Left precedence255}func^^ (left:double, right:double)Double {returnPow (left, right)}println (2^^Ten-2^^3)//1024-8 = 1016
Swift Learning (one): Custom operator operator