Skip to content

Instantly share code, notes, and snippets.

@cafielo
Last active March 12, 2018 16:46
Show Gist options
  • Save cafielo/da90154aca23aa6f9888bf19ec6e575d to your computer and use it in GitHub Desktop.
Save cafielo/da90154aca23aa6f9888bf19ec6e575d to your computer and use it in GitHub Desktop.
protocol Expandable {
var isExpanded: Bool { get set }
}
class Bag: Expandable {
var isExpanded = true
}
class CarryOn: Expandable {
var isExpanded = true
}
class Closet: Expandable {
var isExpanded = true
}
let bag = Bag()
let carryOn = CarryOn()
let closet = Closet()
let expandableItems: [Expandable] = [bag, carryOn, closet]
// expandableItems.forEach { $0.isExpanded = false } // Here !!! I got an immutable error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment