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

S B
S B
4,497 Points

Swift Programming Concepts and how they relate to memory management and storage

Hi there, I have a hardware background, and would like to understand how Swift programming relates to storage behaviour. I'm curious about and would love to know the answers to the following:

In the following statement: let musicLibrary = MusicLibrary().library

When the constant value (musicLibrary) is given a value of a struct (MusicLibrary(), and a dictionary inside it (library)), is the entire dictionary stored into the musicLibrary constant before the struct is run (i.e. when the program compiles), or when the actual line has been reached?

1 Answer

Chris Adamson
Chris Adamson
132,143 Points

It will do the assignment when the line has been reached, i.e. at runtime.

S B
S B
4,497 Points

Thank you Chris!