Classes
Model everyday objects using classes!
StartKey Concepts
Review core concepts you need to learn to master this subject
Swift Class
Instance of a Class
Class Properties
init()
Method
Inheritance
Overriding
Reference Types
Swift Class
Swift Class
// Using data types:
class Student {
var name: String
var year: Int
var gpa: Double
var honors: Bool
}
// Using default property values:
class Student {
var name = ""
var year = 0
var gpa = 0.0
var honors = false
}
A class is used to programmatically represent a real-life object in code. Classes are defined by the keyword class
followed by the class name and curly braces that store the class’s properties and methods.
Classes
Lesson 1 of 1
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory