Explore the basic data types in the Swift standard library. Several data types are covered, including strings, characters, and signed and unsigned whole integer numbers.
- [Voiceover] Instances of a value or a reference type…are declared as either variables or constants.…Variables are declared using the var keyword,…as seen here, and I've done several times…in previous videos already.…A variable is mutable, so I can change it…after the initial assignment.…Constants are defined using the let keyword,…and they are not mutable.…If you try to change a constant, a fix-it suggestion…will typically offer to change that definition for you.…
I'll just comment out this code for now,…pressing Command + / on the keyboard.…If you're coming from Objective C,…you might be looking for pairs of classes,…such as NSString and NSMutableString,…that determine mutability.…Not in Swift; a Swift string is a string.…If it's declared as a variable, it's mutable.…If it's declared as a constant, it's immutable.…A best practice in Swift is,…when you're creating an instance of a type,…create it as a constant to begin with.…This will help you make your Swift code safer…and your intention more clear.…And it allows the compiler to perform some optimizations…
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.