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 trialgökhan sayılgan
2,285 Pointsin incrementBy challenge i didn't under stand what it mean by add values to width and height example please
in incrementBy challenge i didn't under stand what it mean by add values to width and height could you please give me an example i stucked here , gives error :(
class Button {
var width: Double
var height: Double
init(width:Double, height:Double){
self.width = width
self.height = height
}
func incrementBy (points: Double) -> Double {
return points = (width: 1.0 * height: 1.2 )
}
}
2 Answers
Chris Shaw
26,676 PointsHi gökhan,
The challenge is simply asking for you to increment the values of height
and width
by adding the value of points
onto them which you can do by reassigning the values and using the addition operator or using the shorthand increment operator.
func incrementBy(points: Double) {
self.height += points
self.width += points
}
OR
func incrementBy(points: Double) {
self.height = self.height + points
self.width = self.width + points
}
Happy coding!
gökhan sayılgan
2,285 PointsThank you friend i found myself as you show at first version but you teach me also second type if i were have a right to give 12+ more points would give it for that :):):)
var points: Double = (12.0 * 12.0)
func Answer(points: Double) { self.ChrisUpjohn = self.ChrisUpjohn + points } :):):):):)