Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

jon kelson
jon kelson
5,149 Points

Structs and class in object swift

Hi all, in the set of videos object oriented swift . Just for arguments sake could the struct that Pasan made, be a class and the classes been struts ? I'm guessing he just made them different just to show us the difference . ?

1 Answer

Hello Jon:

Just to answer your question.. Yes he could have.. But depending on your project you may want to know which one to use. IN a more general Idea, structs are the way to go, but keep in mind that classes are powerful because of their inheritance. One is a reference type (class), and the other one is value type (struct).

Good luck