Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Nicolás Melgarejo
13,891 PointsSWIFT 4 upgrade code
enum ColorComponent {
case rgb(CGFloat, CGFloat, CGFloat, CGFloat)
case hsb(CGFloat, CGFloat, CGFloat, CGFloat)
func color() -> UIColor {
switch self {
case .rgb(let red, let green, let blue, let alpha):
return UIColor(red: red/255.0, green: green/255.0, blue: blue/255.0, alpha: alpha)
case .hsb(let hue, let saturation, let brightness, let alpha):
return UIColor(hue: hue/360.0, saturation: saturation/100.0, brightness: brightness/100.0, alpha: alpha)
}
}
}
1 Answer

Bruce Röttgers
18,211 PointsXcode can upgrade the code for you (if you’re on the right Xcode version). Else please format the code right.