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

iOS

Help on challenge! Cant seem to add points to the width and height properties.

1 Answer

Hi Pablo,

So we need a func that takes a Double called points and adds that to both the width and height of the object we're in.

Start by defining a method with the right name which takes one parameter which is a Double, the same as the two variables we're trying to alter. That looks like: func incrementBy(points: Double)

Inside that we need to add points to both the width and height member variables. Remember to use self. to make it very clear what you're doing. And to increment by a number you can use the += operator. Put all that together and you get:

  func incrementBy(points: Double) {
    self.width += points
    self.height += points
  }

Hope that helps.

Steve.