Skip to main content

Operators

  • Chapter
  • First Online:
Migrating to Swift from Flash and ActionScript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics