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 trialJoseph Endsley
8,680 PointsHow do I declare a struct named User?
How do I do this, I don't understand?
// Enter your code below
struct Location {
let latitude: Double
let longitude: Double
}
class Business {
let name: String
self.name = name
let location: Location
init(name: String, location: Location){
self.location = location
}
}
let someBusiness = Business(name: "Bookshop", location: Location(latitude: 12.3, longitude: 3.4))
1 Answer
KRIS NIKOLAISEN
54,972 PointsI'm not sure where the code you provided is coming from but you should be able to use this:
struct Location {
let latitude: Double
let longitude: Double
}
as an example. There you have a struct named Location with two properties, latitude and longitude, both of type Double. Just do the same with the names and types specified in the challenge.
Joseph Endsley
8,680 PointsJoseph Endsley
8,680 Pointsthank you