Join Harrison Ferrone for an in-depth discussion in this video Value vs. reference types, part of Learning Swift 3 for Developers.
- [Harrison] Let's get right to some definitions…so we can keep going with our Swift code.…In Swift, all structures and enumerations are value types,…meaning they are copied whenever they are declared…or used elsewhere in your files.…The cool thing is every basic type in Swift is a struct…so integers, arrays, dictionaries, even booleans…all behave the same way under the hood.…Classes, on the other hand, are reference types.…This probably won't be news to you…but it's important to hit the basics…when working with a new language.…
Classes won't be copied…when they are instantiated as variables.…Instead, a reference is created…to an instance of the class.…If you're coming from a language like C++…where the concept of pointers is prevalent,…you'll already be familiar with dealing with references.…The important part to realize here…is that since all basic types in Swift are value types,…they're incredibly flexible,…and have a wide range of uses…whereas in languages like C# or C++,…this might not be the case.…
When you're choosing between making an object…
- 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.