Join Scott Gardner for an in-depth discussion in this video Use overflow operators, part of Swift 3 Essential Training: Beyond the Basics.
- [Voiceover] If you attempt to perform an…arithmetic operation on an integer variable that…results in a value that is too large,…you'll get an error by default.…For example, if I try to add one to UInt8.max,…I'll get an error.…I'll comment that out,…and I'll click the EXC playground button to…clear out that error.…Swift offers three overflow operators,…written with an ampersand preceding…the regular operator symbol…that let you opt in to overflow handling and avoid an error.…
Overflow addition will wrap around from an integer's…maximum value to its minimum one.…For example, for an unsigned eight-bit integer A,…which has a maximum value of 255,…A overflow add one wraps around to its minimum value, zero.…The wraparound accounts for one increment,…and for a signed eight-bit integer B,…with a minimum value of negative 128,…B overflow subtract one wraps around to…its maximum value, 127.…
The wraparound accounts for one decrement.…The third overflow operator handles multiplication overflow.…For example, for an unsigned eight-bit integer C,…
- Adding source files, resources, links, and literals
- Adding pages to a playground
- Using overflow operators and bitwise operators
- Using ranges with strings
- Creating complex sequences
- Chaining higher-order functions
- Defining lazy properties
- Using failable initializers
- Mutating methods
- Working with singletons
- Nesting function types
- Creating error types and recursive enumerations
- Extending concrete types
- Referencing selectors and key paths
- Working with protocol-oriented programming
- Defining class-only protocols and optional protocols
- Using option sets, type checking, and casting operators
Skill Level Intermediate
Core Data for iOS and macOS Enterprise Developerswith Jon Bott1h 46m Intermediate
Distributing Your iOS App for Testing with TestFlightwith Ron Buencamino35m 10s Intermediate
iOS App Development: Test-Driven Developmentwith Harrison Ferrone2h 14m Intermediate
3. Strings and Characters
4. Sequences and Collections
5. Control Flow
6. Value and Reference Types
9. Access Control
Understand access control3m 47s
Next steps1m 2s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.