Learn how to loop repeatedly until a specified condition resolves to false. Additionally, understand the difference between the while and repeat-while statements.
- [Instructor] The while loop repeatedly executes the code…in its body until a condition evaluates to false.…I've imported foundation…to use it's arc4random_uniform function…which takes an upper bound value and returns a number…from zero to that upper bound, 10 in this case.…I'll add one to it.…This will give me a random number from one to 10,…and I'll check to see if that number is less than 10,…and while that is true I'll print a dot using…an empty string terminator,…so that they are printed in line.…The while loop initially evaluates the condition.…In other words, it may not execute the code…in its body even once…if the conditional expression initially resolves to false.…
You can click the play button in the bottom left-hand corner…to force the playground to repeatedly execute your code…in case you'd like to try a few times to see…if you can get 10 to be the first random value.…In which case, nothing is printed.…I'll execute an empty print statement before moving on,…so that the next print statement I execute will begin…
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?
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.