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 trialCory Marco
10,734 PointsCustom Init to Create a Property Description from the RGBA Values
The challenge is for me to create a description from the given values of RGBA
The description is suppose to look like this. "red: 86.0, green: 191.0, blue: 131.0, alpha: 1.0"
I am trying to figure out why I am getting this error:
Bummer! The value of description does not match with the directions specified.
I am unsure if the program wants me to give it values of: R-86.0, G-191.0, B-131.0, A-1.0 values or if my description is off by a slight error. For instance a space or , being out of place.
It could also be I am not following directions the right way.
I have tried to multiple ways and yet I still seem to get the same error.
Thank you in Advanced for any help.
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
description = "red:\(red),green:\(green),blue:\(blue),alpha:\(alpha)"
}
}
2 Answers
Reed Carson
8,306 PointsI literally just finished this task. The only thing I can see is that in your string interpolation there is no space between "red:(red)" etc. My code looked the same except for "red: (red)". very similar but to a computer it can be leagues apart.
Cory Marco
10,734 PointsThat was it.
That you very much.
I seems silly how such small things can make it "fail". But it is good practice.