Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Eric Mentele
7,325 PointsWhy won't width allow points to be added?
It keeps saying that I need to add points to width within the method. This is what I have right now:
func incrementBy(points: Double) -> (width: Double, height: Double) {
return (width + points, height + points) }
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
func incrementBy(points: Double) -> (width: Double, height: Double) {
return (width + points, height + points)
}
}
2 Answers

Ben Goertz
3,411 PointsI tried your code in a Swift Playground and it works, so I think this is just an example of Treehouse preferring a specific answer to pass the quiz.
I was able to complete the quiz by not returning the values, but instead mimicking what we saw in the previous video. Following Amit's example, I simply updated the values by adding points
to the existing stored values. So width = width + points
.
Both solutions work in the Swift Playground, but their automated grading system prefers this solution.
Hope that helps!

Eric Mentele
7,325 PointsThank you! I was not sure that this question posted. I figured that out after re-watching the video. Realized I was creating new values only relevant to the function rather than changing the class's properties values. This was my answer:
func incrementBy(points: Double) {
width += points
height += points
}

Ben Goertz
3,411 PointsAwesome! Glad that worked. Great shorthand with the +=
operator!