Learn how to inspect, access, sort, and modify arrays using a variety of properties and methods. Create multidimensional arrays and access nested elements using extended subscript syntax.
- [Narrator] I'll continue in the same exercise file…from the previous video.…There are a variety of ways to inspect…and access the elements of an array.…Array has a count property…that returns the current count of its elements,…and it has an is empty property…that will return true or false.…An array can also be checked to see…if it contains a value using the contains method,…passing the value to be checked.…Existing elements of an array can be retrieved…or changed using subscript syntax.…In other words, write the index number…of the value you want in square brackets…after the array value name.…
And remember, array indexes begin…with zero so the second element is at index one.…Just be sure to only index existing values…or else you get an index out of range error.…First and last will return, not surprisingly,…the first and last elements of an array,…but note that these are optional values…because an array might be empty…and therefore there are no first or last values.…If you're sure an array is not empty,…you can use the force unwrap operator to unwrap 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.