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 trialMartel Storm
4,157 PointsSwift 3 Object Orientation I got this wrong on the quiz. Can someone please explain? I'm clueless
How do we refer to an instance of a class or a struct from within the definition of an object? Class.self My answer but I was pretty unsure of it Struct.self self this
1 Answer
Alexander Davison
65,469 PointsTo refer to a class inside of a class, you just need to say self
.
Keep in mind that you are only able to do this when the code is inside this class!
When you are outside of the class (in code), you must refer to the class by using the class name.
I hope this helps.
~Alex