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 trialRa Bha
2,201 PointsWhy is the code `` location = invader.Location; needed `` when earlier code had set the Location field to location?
In 3:41 of the video, the code already has
invader.Location = location;
before adding
location = invader.Location;
The presenter says this second statement "gets the location from the invader and sets it back into the local variable location." I am not quite clear on why this second statement is needed if the invader.Location = location;
already exists. Per the video on Fields (link)[https://teamtreehouse.com/library/fields] the first statement already used dot notation to allow us to access the Location field and it was set to location.
Am I missing something?