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!
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

jon kelson
5,149 PointsRGBcolor
hi please could you tell me what im doing wrong
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)"
}
}
3 Answers

Tobias Helmrich
31,602 PointsHey Jon,
you almost got it right but there's only one tiny mistake: You have to interpolate the constants inside of the description
String with a backslash instead of a forward slash like so:
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)"
}
}
I hope that helps! :)

jcorum
71,828 PointsI pasted it into Xcode and it looked good except for one very strange issue. struct didn't turn purple, like it should. So I deleted it and retyped it and it turned purple. Also, there were 4 typos. String interpolation is (...), not /(...):
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)"
}
}
//if I remember correctly colors have to be fractions with divisors of 255
let color = RGBColor(red: 23/255, green: 235/255, blue: 155/255, alpha: 0.8)
color.description
This displays:
"red: 0.0901960784313725, green: 0.92156862745098, blue: 0.607843137254902, alpha: 0.8"

jon kelson
5,149 PointsOk thanks jcorum I'll try that later aswell . Many thanks

jon kelson
5,149 PointsAhh thanks Tobias I should know that by now !
jon kelson
5,149 Pointsjon kelson
5,149 Pointssorry its all Squashed up