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

Final Exam OOP

Why my code crashes on the line where I wrote the convenience init? it complains saying argument 'sides' must precede argument 'name'

I check out the solution after having done it by my self and see that I did not include convenience init. I fallowed as on the video but it crashed!

please explain why does it crashes ? is because of lately update ? if yes please show me how to fix it?

also please could you explain why we are using a convenience init? what we do we use it for? A lot thanks in Advance.

lass Shape {
    var sides: Int
    var name: String

    init(sides: Int, name: String) {
        self.sides = sides
        self.name = name
    }
}

class Square: Shape {
    var sideLength: Double
    var area: Double {

        get {
             return sideLength * sideLength

        }

        set {
            sideLength = sqrt(newValue)
        }
    }

    init(sideLength: Double,sides: Int, name: String) {
        self.sideLength = sideLength
        super.init(sides: sides, name: name)
    }

    convenience init(sideLength: Double) {
        self.init(name: "Square", sides: 4, sideLength: sideLength)
    }
}