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 Swift 2.0 Enumerations and Optionals Introduction to Enumerations Methods on Enumerations

Vassilis Krikonis
Vassilis Krikonis
3,997 Points

is this the right way to use enums?

I didn't like this video. Why getting into all this trouble to define a function that shouldn't belong there. I mean, a function like colour() that just converts values is clearly a helper function that should be separated from this enum. The Colors enum should have the enumerations of the possible values. Even if this video is just for the sake of letting us know the different possibilities with enum, it ends up being confusing.

So yeah, my question is: is this a "real-life" scenario or use-case of enums, with functions inside them like this?

1 Answer

Andrea Miotto
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andrea Miotto
iOS Development Techdegree Graduate 23,357 Points

Hi Vassillis, I don't know if you are doing the techdegree, but inside, there is a project ("Enhancing a Quiz App in iOS"), that you should archive before this video. In the project you have to use many times UIColor, and in this case a function color() like this one, would be very useful.

Anyway, like you said, the video is just for the sake of letting us know the different possibilities with enum.