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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Joshua W](https://secure.gravatar.com/avatar/efbc66a35833e6e08e38f438a7b5ef89?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Joshua W
4,345 Pointscannot get pass the quiz
please see my code, thanks struct RGBColor { let red: Double let green: Double let blue: Double let alpha: Double
let description: String
// Add your code below
init()
{
red = 86.0
green = 191.0
blue = 131.0
alpha = 1.0
description = "red: 86.0, green: 191.0, blue: 131.0, alpha: 1.0"
}
}
1 Answer
![Nathan Tallack](https://uploads.teamtreehouse.com/production/profile-photos/4003052/micro_NathanBusinessEditedSquare.jpg)
Nathan Tallack
22,160 PointsOk, let's take a look at how the struct is setup and how the code comes together.
struct RGBColor {
let red: Double
let green: Double
let blue: Double
let alpha: Double
let description: String
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)"
}
}
Key points are:
1: We declare our properties (red, green, blue, alpha, description) as part of the Struct.
2: We make our init method that takes in the passed arguments from the object creation.
3: See we are not passing description in because that is a computed property.
4: That computed property is why we need to make our own init method.
So then a user would create a RGBColor object with a command like this.
let bgColor = RGBColor(red: 86.0, green: 77.0, blue: 55.0, alpha: 128)
That computed property description would then look like this.
"red: 86.0, green: 77.0, blue: 55.0, alpha: 128.0"
I hope this helps clear it up for you. :)
![Trent Christofferson](https://uploads.teamtreehouse.com/production/profile-photos/6253732/micro_241372963_187625796729552_3431139255907713985_n.jpg)
Trent Christofferson
18,846 PointsOMG THANK YOU SO MUCH!!! y dont we need to put description: String in parentheses with red: Double and all the other ones
Brendan Whiting
Front End Web Development Techdegree Graduate 84,736 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,736 PointsThere's a forum bug - it doesn't actually attach the code when it says it will. Can you edit and paste in your code?