Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Joe Scotto
8,282 PointsCan computed properties have multiple properties on the setter
I'm very new to swift and have been having a hard time figuring out computed properties. Is there a way to pass in multiple properties to a setter or are you limited to just one? I'm attempting the following code but receive this error Expected '{' to start setter definition and Expected '}' after setter parameter name
I'm confused as to the whole type defining in swift also and have tried passing a dictionary into the setter but that then causes issues with my return type.
The code I currently have:
struct Shape {
var height: Int = 0
var width: Int = 0
var area: Int {
set (width, height) {
self.width = width
self.height = height
}
get {
return self.width * self.height
}
}
}