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 trialWilliam Crawford
4,319 PointsStuck on Weather Init challenge
I have tried 20 different ways to do this challenge, without success: The following code compiles just fine, but fails the challenge
struct Vehicle {
var numberOfWheels: Int
var numberOfDoors: Int
var color: String
init(numberOfWheels: Int, numberOfDoors: Int, color: String) -> (Int, Int, String) {
self.numberOfWheels = 4
self.numberOfDoors = 4
self.color = "Blue"
} }
2 Answers
agreatdaytocode
24,757 PointsHello William,
Try adding the following code within the Vehicle struct. Then, fill in the values.
init () {
numberOfWheels =
numberOfDoors =
color =
}
William Crawford
4,319 PointsThanks, Aaron. I swear I had tried that before. Obviously not. Yours worked fine. Bill
agreatdaytocode
24,757 PointsAnytime. I'm glad to help.
Forrest Wilson
21,862 PointsForrest Wilson
21,862 PointsIf you Copy/Paste your code into an Xcode playground, see what errors pop up and see what needs to change in your code.