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 trialAaresh Jalnawalla
2,363 PointsUnable to do the code challenge...
struct Location { let latitude: Double let longitude: Double let name: String //should I write let name: String here or in the class. I dont understand. The question mentions in the class. Logic says you should mention it here too. }
class Business { let name: String // or here? or both? The question is too confusing. let location: Location // I dont even know if this is the right line of code to write? What does location of type Location in the question mean?
init(x: Double, y: Double, name: String) {
self.someBusiness = Location(latitude: x, longitude: y, name: name)
}
} let location = // I don't know what to write here. let Business = Location(latitude: 12.345, longitude: 21.456, name: "Some Business")
I find the code challenges too difficult to complete lately. I can't understand a single challenge without referring to the answers of other users in the last 5-6 challenges. In fact, I find the questions too confusing and ambiguous. I understand the instructor wants you to think and answer and not spoon feed students but as a rookie to coding it becomes extremely difficult to follow. I feel there needs to be some more "being explicit" in the questions or concepts to make a beginner understand. I've been struggling hard and trying to move on since a while but now I'm stalling. How do I ask more than 2-3 questions in 1 code challenge without talking to someone? I don't know if I can continue this way?
3 Answers
Nils Garland
18,416 PointsThis should fix it. I recommend you re-watch some videos before moving on.
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 location = Location(latitude: 34.0, longitude: 32.0)
let someBusiness = Business(name: "Treehouse", location: location)
Nicholas Richardson
4,867 PointsI completed the challenge as follows and arranged the wording in a way that made a bit more sense to me.
struct Location {
let latitude: Double
let longitude: Double
}
class Business {
let name: String
let location: Location
init(name: String, latLocation: Double, longLocation: Double) {
self.name = name
self.location = Location(latitude: latLocation, longitude: longLocation)
}
}
let someBusiness = Business(name: "Apple The Grove", latLocation: 34.072780, longLocation: -118.357609)
Alia Khan
3,733 Pointsclass Business {
let name: String
let location: Location
init(name: String, location: Location) {
self.name = name
self.location = location
}
}
let someBusiness = Business(name: "Apple", location: Location(latitude: 0.0, longitude: 0.0))