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 Getting Rid of Strings

Kinda Stuck... Answers?

Yeah so I tried doing this next challenge but I don't quite remember how to use classes properly, so can someone post the answer to it. And not just so I can "Copy", I legit want to use it for learning purposes.

https://teamtreehouse.com/library/swift-20-enumerations-and-optionals/introduction-to-enumerations/enums-and-objects

1 Answer

Paul Brazell
Paul Brazell
14,371 Points

In your move function, all it is asking you to do is to specify what happens when a direction is chosen to be moved. Switch statements are awesome for this. Simply specify what happens to the location's x and y values when a direction is chosen.

    func move(direction: Direction) {
        // Enter your code below
        switch direction {
        case .Up: location.y += 1
        case .Down: location.y -= 1
        case .Right: location.x += 1
        case .Left: location.x -= 1

        }
}