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 struct data types

When we create multiple instances of a struct type are those various instances indexable? I am thinking of c++ where you can create arrays of struct types that are ordered, do structs in Swift have the same functionality? Or should I use dictionaries instead?

1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Eli Goodwin,

Yes, you can store your own struct data types inside of Arrays. You can make an array of other types implemented behind the scenes using a struct eg. Int, String, Double so this shouldn't be a problem.

Good Luck