Thanks! Reading that article helped a lot!
class Bike {
var color: String
init(color:String) {
self.color = color
}
}
var bike1 = Bike(color: "Blue")
var bike2 = bike1 // < The behavior I thought was a default
// behavior of classes, only happens when
// you set two class instances equal to
// each other. As is done here.
bike1.color = "Red"
print(bike2.color) // prints Red
In this example, the behavior is not present:
// define a class
class Employee {
// define a property
var employeeID = 0
}
// create two objects of the Employee class
var employee1 = Employee()
var employee2 = Employee()
// access property using employee1
employee1.employeeID = 1001
print("Employee ID: \(employee1.employeeID)")
// access properties using employee2
employee2.employeeID = 1002
print("Employee ID: \(employee2.employeeID)")
Output:
Employee ID: 1001
Employee ID: 1002