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 trialNiilo Pirttijärvi
Courses Plus Student 2,354 PointsI don't understand why some things are done in the tutorial?
override init(x: Int, y: Int){
super.init(x: x, y: y)
}
I don't understand why the super.init(x: x, y: y)
part was needed. I understand how and why the override
is used but not what the super.init
part here is doing?
1 Answer
Jari Koopman
Python Web Development Techdegree Graduate 29,349 PointsHi Niilo,
Because you're overriding the init from a superclass, you have to first initialise the superclass, before you can start doing things for the subclass. More info on subclassing can be found in the docs under Initializer Inheritance and Overriding
Hope this helped,
Regards, Jari