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 Enum Members and Raw Values

Radomir Stanev
Radomir Stanev
2,415 Points

Can't pass the turtleSpeed variable challenge. Any ideas why?

When I paste the exact same code in Xcode it seems to be working, but I can't pass the challenge.

enum.swift
enum Speed: Int {
    case Slow = 10, Medium = 50, Fast = 100
}

var turtleSpeed = Speed.Slow
Radomir Stanev
Radomir Stanev
2,415 Points

This is what I get when trying to submit it: Bummer! The variable 'turtleSpeed' was expected to be of type 'Int', but it wasn't.

1 Answer

Logan R
Logan R
22,989 Points

You've almost got it. You need to add .rawValue to the end of your call.

var turtleSpeed = Speed.Slow.rawValue

You can rewatch the video and listen to him talk about it at 3:50 [https://teamtreehouse.com/library/swift-enums-and-structs/enums/enum-members-and-raw-values].