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 trialprat pandy
154 PointsI'm not understanding what is wrong with this code
I'm not understanding what is wrong with this code
struct RGBColor {
let red: Double
let green: Double
let blue: Double
let alpha: Double
// 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
let description: String = "red: \(self.red), green: \(self.green), blue: \(self.blue), alpha: \(self.alpha)"
print(description)
}
var temp = RGBColor(red: 86.0, green: 191.0, blue: 131.0, alpha: 1.0)
1 Answer
Moritz Lang
25,909 PointsHey Prat,
you're doing good. Remember that you cannot call a method such as print()
outside another block. If the task was to print a description to the console you should use a method instead:
func description() {
print("red: \(red), green: \(green), blue: \(blue), alpha: \(alpha)")
}
You would call this method by writing temp.description()
.