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 2.0 Complex Data Structures Custom Initializers

Paul Lavier
Paul Lavier
1,081 Points

The check work function does not seem to recognize my init method. Could it be missing it or am I making some huge error

I entered a init that seem to work in the playground but it does not seem to be recognized by the "Check Work" function.

    init(red: Double, green: Double, blue: Double, alpha: Double, description: String) {
        self.red = red
        self.green = green
        self.blue = blue
        self.alpha = alpha
        self.description = "red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)"
    }

2 Answers

Hi Paul,

You don't pass description in as a parameter. It is created inside init using the other four stored properties that you do pass in.

Make sense?

    init(red: Double, green: Double, blue: Double, alpha: Double) {  //  no description here
        self.red = red
        self.green = green
        self.blue = blue
        self.alpha = alpha
        // create it here
        self.description = "red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)" 
    }

Steve.

Paul Lavier
Paul Lavier
1,081 Points

Yes. That makes sense. Thanks