Tour basic arithmetic operators and methods in Swift. Understand when conversion between types is necessary and when the compiler will perform the conversion for you.
- [Instructor] Swift includes a complete set…of basic arithmetic, comparison, and logical operators.…And I have included several examples here.…You have your basic arithmetic operators…that work with integers…or floating-point numbers, as expected.…the compiler will convert numeric integer literals…to floating points, if there is a floating-point literal…used in that expression.…And double is the default type.…However, if I explicitly define a float numeric literal,…such as a bypassing of floating-point literal…to the float initializer, then the integer literal…will be converted to match.…
The compiler will not automatically convert…a variable or a constant value though.…In this case, you have to use initializers…to make all the variable or constant values…in the expression, be of the same type as the literals.…The above operators all return a new value.…There are also mutating operators…that assign the results to the operation to the left side.…These are known as compound operators,…each of these compound operators performs the operation…
Learn how to write code, understand Swift's key concepts and best practices, and strengthen your programming problem-solving skills. Instructor Scott Gardner teaches the fundamentals, so you'll be prepared to develop applications for iOS, macOS, and other platforms. Completing this course will enable you to not only write first-class code, but to think like a Swift developer.
- Creating playgrounds
- Defining variables and constants
- Working with characters and strings
- Working with collections and groups
- Using operators and defining custom operators
- Controlling program flow
- Defining functions and closures
- Working with classes, structures, and enumerations
- Adopting protocols
Skill Level Beginner
1. Get Started
2. Variables and Constants
3. Characters and Strings
4. Collections and Tuples
6. Control Flow
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.