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 trialIsaac Gonzalez
2,736 PointsWhy does your system say my code is incorrect?????
My code seem correct to me, I have no clue why I keep getting an error.
struct RGBColor {
let red: Double
let green: Double
let blue: Double
let alpha: Double
let description: String
// Add your code below
init(red: Double = 1.0, green: Double = 2.1, blue: Double = 3.2, alpha: Double = 4.3, description: String) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
self.description = "red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)"
}
}
let newColor = RGBColor(red: 45.9, green: 34.21, blue: 78.98, alpha: 1.0, description: "")
1 Answer
Amazon Web
iOS Development Techdegree Student 4,092 PointsBecause you create a init method with default values in the parameters. Also you don't need to add the description parameter in the init method because you will get the value of description property by creating string inside the init method.
struct RGBColor {
let red: Double
let green: Double
let blue: Double
let alpha: Double
let description: String
// Add your code below
init(red: Double, green: Double, blue: Double, alpha: Double) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
self.description = "red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)"
}
}
let red = RGBColor(red: 86.0, green: 191.0, blue: 131.0, alpha: 1.0)