Operations on Integers
Swift allows you to perform basic mathematical operations on integers using the familiar operators +
(add), -
(subtract), and *
(multiply).
You can include these operations in your code; in a playground, you can also just enter them to see the result. Try it.
... let numberOfPeople: UInt = 40 40 let volumeAdjustment: Int32 = -1000 -1000 10 + 20 30 30 - 5 25 5 * 6 30
A quick aside: Usually, the whitespace in your code (like the number of spaces you indent or any blank lines you leave) does not matter. If you prefer more or less indentation or blank lines than this book shows, that is fine. But occasionally whitespace does matter, and now is one of those times. When you are using ...
Get Swift Programming: The Big Nerd Ranch Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.