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 trialLeonardo Cavalcanti
5,308 PointsIncrementby challenge class object oriented swift basics
Help? It seems to work on Xcode
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
func incrementBy(points: Double){
height = height + points
width = width + points
}
}
1 Answer
Jhoan Arango
14,575 PointsHello Leonardo:
So your method looks good, but you are giving the wrong values to width and points.
width = width + points is not going to work for this challenge.
try
width = points
Good luck
Kamran Ismayilov
5,753 PointsKamran Ismayilov
5,753 PointsHello Jhoan, I did not get why are we assigning width to points? Can you please show me complete code and explain why you did so ? Appreciation in advance!
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHello Kamran:
We are not assigning width to points, its the other way around. Points to width.
Hope this answers your question.
Leonardo Cavalcanti
5,308 PointsLeonardo Cavalcanti
5,308 PointsI don't think I gave the wrong values what you did is just a different way of doing the same thing... But thanks, it worked anyway...