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,455 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!