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 Object-Oriented Swift Classes and Objects Classes and Their Methods

Classes and their methods

Hello, i'm stuck on this challenge. Can someone help me ?

This is what i have to do: We need to provide a means to increase the size of our Button. So we are going to add a method named incrementBy which will accept a parameter named points. (Within the method add points to the width and height properties).

My error is that my code could not be compiled. But when i preview my code it sais nothing

class Button {
  var width: Double
  var height: Double
  var points: Double

  init(width:Double, height:Double, points:Double){
    self.width = width
    self.height = height
    self.points = points
  func incrementBy(points: Double) {


1 Answer

Hey Mathis, in order to increment the button's width and height by the value passed in the points parameter you would add these two lines:

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

Hope this helps!

Thanks a lot, it worked!

David Maybach
David Maybach
2,092 Points

why not include return so ....return.width += points and so forth for height?