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 trialalexr89
4,045 PointsWhy was the init method needed?
Why was the init method needed in this video, when the method worked fine without it?
I don't understand why you would need to set up an init method to set up an object ready for use, when it seemed to work perfectly fine in setting itself up without this init method.
It just seems like extra code to type out.
2 Answers
lvwdhydynw
6,443 PointsI think your question is answered within the first 15 seconds. In case of structures, you don't need to type out init method as it's "created" automatically. However, we did this to see how it works and try to understand as with classes, you will need to know how to do it! :)
Jeff McDivitt
23,970 PointsThis should answer all of your questions
alexr89
4,045 Pointsalexr89
4,045 PointsExactly, if a structure automatically creates an init method, why would we ever need to manually create an init method for a struct? Why is it even an option or possible, why are we not told that its not needed and done automatically?