Learn how to use half-open and closed range operators to create and represent sequences, as well as how to use range operators to index into a subset of a collection.
- [Instructor] Range operators in Swift…are used to represent a range of values.…Ranges have undergone significant changes in Swift 3.…There are two kinds of range operators,…half-open and half-closed.…The half-open range operator…is used to define a range from the start value…to, but not including, the end value.…That would mean this range is from zero to nine,…so its count is 10.…The closed-range operator is used to define…a range that includes both the start and the end values.…That is, from the start value through…and including the end value.…
RangeB is from zero to, and including, 10,…so its count is 11.…Let's say I want to replace a subrange of an array.…I'll define an array of integers…called fibonacciNumbers.…There's just one problem,…these aren't the Fibonacci numbers.…They're triangular numbers.…It just so happens that the first and last numbers…are, coincidentally, Fibonacci numbers.…So, I can replace the middle portion…with the correct Fibonacci numbers…and fix things up.…
Arrays have a replace subrange with method…
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.