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


Min Choi
Min Choi
1,517 Points

What is the standalone definition of a "Construct" in Swift 2.0?

So I guess I missed the video where they explained the definition of a "Construct". I looked for the definition online but all that pops up are links to different construct types in Swift.

1 Answer

If you mean Swift initializers, then the Apple documentation is a possible source: https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html

Other programming languages like Java use the term constructor rather than initializer, but sometimes when folk are working in both languages it's possible they may use constructor in a swift class when they mean initializer.

Whatever, initializers are "special" methods whose main job is to make sure that all member (instance) variables have been initialized.

To borrow an example from the Apple documentation:

struct Fahrenheit {
    var temperature: Double
    init() {
        temperature = 32.0

Here's a sample struct, Fahrenheit, with one member variable, temperature. The initializer init() is setting the variable's value to 32.0.