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 trialKittipol Munkatitum
13,074 Pointscould you help me answering this challenge
struct Location { let latitude: Double let longitude: Double let name:String
}
class Business { let someBusiness : Location let name:String = "eiei"
init(x: Double, y: Double , names:String) {
self.someBusiness = Location(latitude: x, longitude: y, name: name)
}
}
I don't know why it error complied could help me solve this challenge
1 Answer
Robert Bojor
Courses Plus Student 29,439 PointsCan you make your question more clear? What error did you receive in the code challenge? (Click the Preview button to see where it crashes).
I have used your code in a Playground and added the last line you see below, and everything looks ok...
struct Location {
let latitude: Double
let longitude: Double
let name:String
}
class Business {
let someBusiness:Location
let name:String = "eiei"
init(x: Double, y: Double , names:String) {
self.someBusiness = Location(latitude: x, longitude: y, name: name)
}
}
let business = Business(x: 43.123456, y: 24.123456, names: "Some Business")```
Robert Bojor
Courses Plus Student 29,439 PointsRobert Bojor
Courses Plus Student 29,439 PointsDid find something, in your init function you have as a parameter names instead of name, but that is covered by the fact that you have declared let name:String = "eiei".