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 trial

iOS Swift Basics An Introduction to Swift Programming Variables

what is a construct?

can somebody explain to me what a construct is? Trying to get a clear understanding on it

1 Answer

Cory Harkins
Cory Harkins
16,500 Points

From what I understand (because I'm learning iOS as well, but have JavaScript experience)

A construct is a way of storing data as an object. Using some basic variables/constants that describe what the object is.

A table will always be a table because it has 4 legs, a platform, and is mainly made from wood.

So if we think of it as an object construct, we can say our basic structure of a table has 4 legs, a platform, and may or may not be made from wood.

When describing that in code, instead of typing those variables for each table we create (nightstand, coffee table, dinner table) we can create a night stand, and tell the nightstand that it will inherit the properties of a table, being 4 legs, a platform, and the material it is made of.

We can make many types of tables and re-use that same object structure.

Hope that helps!