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.

Arthur Boilanger
3,372 PointsExpected Declaration Error
It seems like the code here should be working, but every time I attempt to compile it I'm coming up with the following error: "swift_lint.swift:37:1: error: expected declaration"
Any help is greatly appreciated!
class Point {
var x: Int
var y: Int
init(x: Int, y: Int){
self.x = x
self.y = y
}
}
enum Direction {
case Left
case Right
case Up
case Down
}
class Robot {
var location: Point
init() {
self.location = Point(x: 0, y: 0)
}
func move(direction: Direction) {
// Enter your code below
switch direction {
case Direction.Up: location.y += 1
case Direction.Down: location.y -= 1
case Direction.Right: location.x += 1
case Direction.Left: location.x -= 1
}
}
1 Answer

Steven Deutsch
21,046 PointsHey Arthur Boilanger,
Simple fix. You're missing a bracket to close out your function.
class Point { // open1
var x: Int
var y: Int
init(x: Int, y: Int){ // open2
self.x = x
self.y = y
} // close 1
} // close 2
enum Direction { // open3
case Left
case Right
case Up
case Down
} // close3
class Robot { // open4
var location: Point
init() { // open5
self.location = Point(x: 0, y: 0)
} // close5
func move(direction: Direction) { // open6
// Enter your code below
switch direction { // open7
case Direction.Up: location.y += 1
case Direction.Down: location.y -= 1
case Direction.Right: location.x += 1
case Direction.Left: location.x -= 1
} // close7
} // close6 <--- missing
} //close4
Arthur Boilanger
3,372 PointsArthur Boilanger
3,372 PointsAh... I should've known it was going to be something simple. Spent too much time looking at code lately haha.
Thank you!