我想查找一些运算符的优先级.是否有某个列表?我还没找到一个.
Updated for Swift 3.0
Swift 3.0
现在Swift文档中有一个page.
下面列出了所有优先级组(也可见命令单击导入Swift):
precedencegroup BitwiseShiftPrecedence { higherThan: MultiplicationPrecedence } precedencegroup FunctionArrowPrecedence { associativity: right } precedencegroup AssignmentPrecedence { associativity: right assignment: true higherThan: FunctionArrowPrecedence } precedencegroup RangeFormationPrecedence { higherThan: CastingPrecedence } precedencegroup CastingPrecedence { higherThan: NilCoalescingPrecedence } precedencegroup AdditionPrecedence { associativity: left higherThan: RangeFormationPrecedence } precedencegroup NilCoalescingPrecedence { associativity: right higherThan: ComparisonPrecedence } precedencegroup ComparisonPrecedence { higherThan: LogicalConjunctionPrecedence } precedencegroup LogicalConjunctionPrecedence { associativity: left higherThan: LogicalDisjunctionPrecedence } precedencegroup LogicalDisjunctionPrecedence { associativity: left higherThan: TernaryPrecedence } precedencegroup DefaultPrecedence { higherThan: TernaryPrecedence } precedencegroup TernaryPrecedence { associativity: right higherThan: AssignmentPrecedence } precedencegroup MultiplicationPrecedence { associativity: left higherThan: AdditionPrecedence }
斯威夫特2.1
在Swift标题中:
infix operator %= { associativity right precedence 90 assignment } infix operator >= { associativity none precedence 130 } infix operator != { associativity none precedence 130 } infix operator <<= { associativity right precedence 90 assignment } infix operator || { associativity left precedence 110 } infix operator += { associativity right precedence 90 assignment } infix operator / { associativity left precedence 150 } infix operator - { associativity left precedence 140 } infix operator << { associativity none precedence 160 } infix operator |= { associativity right precedence 90 assignment } infix operator >>= { associativity right precedence 90 assignment } infix operator <= { associativity none precedence 130 } infix operator -= { associativity right precedence 90 assignment } infix operator ?? { associativity right precedence 131 } infix operator > { associativity none precedence 130 } infix operator ~= { associativity none precedence 130 } infix operator + { associativity left precedence 140 } infix operator ^ { associativity left precedence 140 } infix operator ... { associativity none precedence 135 } infix operator /= { associativity right precedence 90 assignment } infix operator * { associativity left precedence 150 } infix operator *= { associativity right precedence 90 assignment } infix operator & { associativity left precedence 150 } infix operator !== { associativity none precedence 130 } infix operator % { associativity left precedence 150 } infix operator && { associativity left precedence 120 } infix operator &* { associativity left precedence 150 } infix operator &+ { associativity left precedence 140 } infix operator &= { associativity right precedence 90 assignment } infix operator >> { associativity none precedence 160 } infix operator &- { associativity left precedence 140 } infix operator === { associativity none precedence 130 } infix operator ~> { associativity left precedence 255 } infix operator ..< { associativity none precedence 135 } infix operator < { associativity none precedence 130 } infix operator == { associativity none precedence 130 } infix operator ^= { associativity right precedence 90 assignment } infix operator | { associativity left precedence 140 }