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 Enums and Structs Enums What is an Enum?

"What is an enum?" Help on Challenge

Hello,

I'm having a bit of trouble with a very simple challenge. Here:

https://teamtreehouse.com/library/swift-enums-and-structs/enums/what-is-an-enum-2

I'm unable to get my code to validate. Following the exact example in the video (below) doesn't work.

// enum Speed { case: Slow, case: Medium, case: Fast}

Some other things I've tried:

// enum Speed { case: "Slow", case: "Medium", case: "Fast"}

// enum Speed : Int { case Slow = 10 case Medium = 50 case Fast = 100 }

I'm sure it's something simple, but I'd appreciate some guidance. Thank you.

1 Answer

Hi Steven,

Try:

enum Speed { case Slow
case Medium 
case Fast}

or:

enum Speed { case Slow, Medium, Fast}

I hope that helps!

Steve.

You don't need the colons after the case keyword. If you separate each case with a comma, you only need to declare case once, too.

Steve.

Thank you! The second example solved my problem.

No problem! :-)