Abstract
We start our exploration of the Swift language with a look at the operators it offers. You will find that your ActionScript experience has prepared you for most of what’s to come in this chapter. The majority of operators look the same and follow the same syntax and rules for associativity and precedence you would expect.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Why is it significant that the assignment operator does not return a result in Swift? More often than not statements like if (a = 3) are a result of a typo, where the intention was to write if (a == 3). So in languages like ActionScript it’s a good habit to put the constant, or the more constant of the two operands, to the left of the comparison operator: if (3 == a). That is, if one of your operands is nice enough to be constant. Why? The ActionScript compiler will let you know that you have made a typo if you mistakenly wrote if (3 = a). The Swift compiler spares you the need to trick it and will instead issue a compiler error if you ever tried to check the result of an assignment operation by mistake or intentionally.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2016 Radoslava Leseva Adams and Hristo Lesev
About this chapter
Cite this chapter
Leseva Adams, R., Lesev, H. (2016). Operators. In: Migrating to Swift from Flash and ActionScript. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-1666-8_18
Download citation
DOI: https://doi.org/10.1007/978-1-4842-1666-8_18
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-1667-5
Online ISBN: 978-1-4842-1666-8
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)