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 trialhector alvarado
15,796 PointsWhat does the set method inside pet looks for?
Kinda lost, when we call the object property it will go to the setter on pet and look how it must be instanciated then go for the Owner class and set with the method on the onwer class inside the pet instantiation, right?
1 Answer
Steven Parker
231,248 PointsThe setter method "owner" on "Pet" does not create an instance of "Owner". But it does allow you to assign one, as is done by the example code:
ernie.owner = new Owner('Ashley', '123 Main Street');
The new "Owner" instance is created by the "new" keyword, and then assigned by the setter method in "ernie".