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

iOS Object-Oriented Swift Complex Data Structures Custom Initializers

Hi, i do not understand where is error

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)"

}
structs.swift
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)"

    }

}

2 Answers

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

It seems like you have an extra space every time you use string interpolation. The correct syntax is \(red) and not \( red). The second one has an extra space in between the opening parentheses and the expression.

Thank you for answer, i did as you said, but i have an error " Make sure the string you're assigning to the description property matches the example in the instructions" =( in playground it works good ))

I did it ) morning good time for solving problems) thank you again )

Thomas Dobson
Thomas Dobson
7,511 Points

As Pasan mentioned, your interpolations contain spaces. I too struggled with this challenge due to spacing in the initialized description string. Pay close attention to that empty space; it matters!!