Join Harrison Ferrone for an in-depth discussion in this video The switch statement, part of Learning Swift 3 for Developers.
- [Narrator] Switch statements are extremely versatile…and one of the most used statements in application code.…Let's take a look at how Swift implements them.…Under the while loop section I'm going to add…a new header comment the switch statement.…I'm going to have a variable here for cat lives,…I'm going to set equal to nine.…Now our switch case example is just going to go through…and decide what to print out from cat lives one to nine.…
If we use the switch keyword,…Xcode is going to give us this little template.…So the value that we're going to switch on is cat lives,…and just for the first case it's going to be case one,…and here we're going to print out I need to be careful here.…For our default case we're going to print out too many risks.…Now, let's handle all the other cases we have.…Case two through five we're going to…print out I can take some risks.…
Case six up until eight we're going to print out…I'm pretty comfortable here.…And for case nine we're going to print out fully loaded.…I'm going to do some indenting here…
- Starting a new playground
- Printing to the console
- Declaring variables
- Working with numbers
- Using strings
- Breaking down optionals
- Understanding closures
- Classes vs. structs
- Extensions and protocols
Skill Level Beginner
1. Hello Swift
2. Back to Basics: Variables and Operators
3. Collections, Tuples, and Enumerations
4. Working with Logic Flows
5. Only in Swift: Optionals
6. Functions, Closures, and Associated Types
7. Classes vs. Structs
8. Advanced Topics
- 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.