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 trialWesley Jacobs
5,865 Pointsclasses with custom types
Help. help. I can't seem to figure out what's wrong with my code. It keeps saying it can't be compiled. The only error I get in Xcode is "expected a separator"
struct Location {
let latitude: Double
let longitude: Double
}
class Business {
let name: String
let location: Location
init(name: String, location: Location){
self.name = name
self.location = location
}
}
let someBusiness = Business(name: "Ross Island", Location(latitude: 12.1, longitude: 12.1)
1 Answer
andren
28,558 PointsThere are two issues:
You are missing a closing parenthesis for your
Location
constructor in thesomeBusiness
constant. That is the cause of the "expected a separator" error.You are missing the
location
parameter label.
If you add them like this:
let someBusiness = Business(name: "Ross Island", location: Location(latitude: 12.1, longitude: 12.1))
Then your code will work.