[swift-users] cast operator precedence

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


I've found here
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

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