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 trialDavide Rigobon
1,822 PointsThis code challenge looks ok for me but when I check it cannot compile it, is it a bug or I'm missing something ?
/Users/DavideRigobon/Desktop/Screenshot 2019-07-17 at 10.00.04.png
struct Location {
let latitude: Double
let longitude: Double
class Business {
let name: String
let location: Location
init(name: String, latitude: Double, longitude: Double) {
self.name = name
self.location = Location(latitude: latitude, longitude: longitude)
}
}
}
let someBusiness = Location.Business(name: "Baketsu live", latitude: 11.7, longitude: 3.78)
2 Answers
Daniel Turato
Java Web Development Techdegree Graduate 30,124 PointsYou're not meant to provide the longitude or latitude in the init for the business but instead an already established instance of Location. Also, you have your class inside the struct whereas it should be outside the struct. So your code would look like this:
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: "test", location: Location(latitude: 2.0, longitude: 2.0))
Davide Rigobon
1,822 PointsThank You very much !!!