Reputation: 73
Is't there a way set multiple variables equal to same value in Swift? like:
self.view1.backgroundColor = .white
self.view2.backgroundColor = .white
self.view3.backgroundColor = .white
make it into one line
self.view1.backgroundColor, self.view2.backgroundColor, self.view3.backgroundColor = .white
Upvotes: 1
Views: 436
Reputation: 30268
Maybe something like this, if you must use a one-liner:
[view1, view2, view3].forEach { $0.backgroundColor = .white }
Upvotes: 8