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 trialTyler Dotson
Courses Plus Student 1,740 Pointswhat do i have to do from here?
i am not sure what the challenge is asking. I feel close but I am not sure what do from here.
struct Location {
let latitude: Double
let longitude: Double
}
class Business {
let name: String
let location: Location
init(name: String) {
self.name = name
self.location = atLocation
}
}
let someBusiness = Location(name: bot, atLocation: 2.0, 3.0)
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyour init needs two parameters, not one - a name and a location. name is a string like you have, location is a Location as given in the starter code. in your init body, you are ok on name but there is no atLocation, it's just going to be self.location = location (you can call it anything really as long as the names match). then it says create an instance of Business, so it's not going to be = Location, it's = Business. you have changed your init to take two arguments, the first is name, and it must be in quotes " " because it's a string. the second is an instance of Location. i did this by instantiating a Location object directly in the call to the Business init. how do we create a Location? well we see it has two parameters, lat and long, so we have to feed those in with values of type double along with the variable names, just like any instantiation in iOS.
Michael DiMartino
3,899 PointsMichael DiMartino
3,899 PointsJames,
After going through your comments, i know i am closed with the following
struct Location { let latitude: Double let longitude: Double
}
but here i run into the issue you were referring to on how to assign the Lat and Long values to the Location type. I have tried changing the init arguments as such to return a Double Double type value :
obviously, still running into problems, am i supposed to be doing something within the immediate Location struct?