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 trialElena Iliasova
iOS Development with Swift Techdegree Student 1,739 Pointsplease tell me what is wrong with my code?
please tell me what is wrong with my code?
class Vehicle {
var numberOfDoors: Int
var numberOfWheels: Int
init(withDoors doors: Int, andWheels wheels: Int) {
self.numberOfDoors = doors
self.numberOfWheels = wheels
}
}
class Car: Vehicle {
var numberOfSeats: Int
init(numberOfDoors: Int, numberOfWheels: Int, numberOfSeats: Int) {
self.numberOfSeats = numberOfSeats
super.init(numberOfDoors: doors, numberOfWeels: wheels)
}
let someCar = Car(numberOfDoors: 4, numberOfWheels: 2, numberOfSeats: 4)
// Enter your code below
1 Answer
Steven Parker
231,184 PointsThe labels in the "super" call need to match the parameters and parent labels, and the class was missing a closing brace.
Brace matching is easier to spot if you consistently use indentation to indicate nesting level.
// labels need to match
super.init(withDoors: numberOfDoors, andWheels: numberOfWheels)
}
} // closing brace was missing
Elena Iliasova
iOS Development with Swift Techdegree Student 1,739 PointsElena Iliasova
iOS Development with Swift Techdegree Student 1,739 PointsThank you so much. the error is fixed and the code works