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 trialSteve Burgos
2,759 PointsI am stuck with how to add the value string to the description item.
I am having trouble understanding where to start on getting the values for the description item to the corresponding colors.
struct RGBColor {
let red: Double
let green: Double
let blue: Double
let alpha: Double
let description: String
init (red: 86,0, green: 191.00, blue: 131.00, alpha: 1.0) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
}
}
1 Answer
jcorum
71,830 PointsGood start. But you don't put values in as parameters for the initializer. They will be passed in when you call the initializer, i.e., when you use the initializer to create RGBColor objects. You wouldn't want every color object to have the same red, green and blue values.
init(red: Double, green: Double, blue: Double, alpha: Double) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
description = "red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)"
}