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 trialolcay cezayir
2,538 Pointsprotocol ColorSwitchable{ func switchColor(_color: Color) } with this, i got an error. Why?
i can not pass the question. i am sure my solution is correct.
// Declare protocol here
protocol ColorSwitchable{
func switchColor(_color: Color)
}
enum LightState {
case on, off
}
enum Color {
case rgb(Double, Double, Double, Double)
case hsb(Double, Double, Double, Double)
}
class WifiLamp {
let state: LightState
var color: Color
init() {
self.state = .on
self.color = .rgb(0,0,0,0)
}
}
1 Answer
Bharath Chandrashekar
iOS Development with Swift Techdegree Graduate 12,055 PointsTry changing βstateβ to a variable from a constant.
var state: LightState