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 trialYenting Chen
5,819 PointsWhy the function under the Struct is able to return the Struct to the function?
In the video, the Function named points is under the Struct named Point.
Why the function can return the Struct?
Can the Function separate from the Struct?
1 Answer
tobikuyo
4,904 PointsMy understanding is that it can return properties of the Point struct, because it is within its local scope, meaning that those properties are accessible to it. The function wouldn't be able to separate from the struct, because in this case the function is a method of the Struct, meaning that once again it only exists within its local scope.