Learn how to control program flow using if and if-else if conditional statements. Additionally, check availability of API based on platforms and versions.
- [Instructor] An "if" statement allows you to define…a conditional expression that, if it evaluates to true,…will execute the body of the if statement.…I'll once again use Foundation's arc4random_uniform function…to generate a random test score from 50 to 100,…and then I'll create an if statement to check…if test score is greater than or equal to 70,…and if so print "You passed!"…An "else" clause can optionally be added…to an if statement, and control will be transferred to it…if the if statement resolves to false.…I'll duplicate this example, and add an else clause onto it.…
An if statement can have only one else clause.…You can nest if statements, and also each if statement…can optionally have one or more "else if" clauses.…In this example, the outer if statement checks if test score…is greater than or equal to 70, and if so,…it incrementally checks if test score…is less than a letter grade cutoff, from C to A,…printing the associated grade, else it prints "A+".…That's a lot of boilerplate code though, isn't it.…
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.