[swift-users] cast operator precedence

Elena Vilchik vilchik.elena at gmail.com
Fri Dec 4 05:21:01 CST 2015


Hello,

I've found here
<https://developer.apple.com/library/prerelease/ios/documentation/Swift/Reference/Swift_StandardLibrary_Operators/index.html#//apple_ref/doc/uid/TP40016054>
that "as" operator has a lower precedence than "*" operator (132 vs 160).
Why then this code compiles if multiplication should be made first?

var x = 1
print(x as Int * 100)

Conversely this code doesn't compile (as expected) - multiplication is made
first:

var x : Float = 1
print(100 * x as Int)

------
Elena Vilchik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151204/744a2054/attachment.html>


More information about the swift-users mailing list