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

Jeff Wilkey
Jeff Wilkey
10,296 Points

Adding a dictionary to an array item (Swift Basics: Collections)

Trying to add a dictionary to an array item as the extra credit for that section assigns. But I can't seem to figure it out I've tried doing this but obviously its wrong haha Any help on how this could be accomplished? <a href="http://imgur.com/8i4IU7E"><img src="http://i.imgur.com/8i4IU7E.png" title="source: imgur.com" /></a> http://i.imgur.com/8i4IU7E.png

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

In Swift (unlike some other languages), arrays can only be of a single type. So if you want dictionaries in an array, every item in the array has to be a dictionary. You can't have some strings and some dictionaries. Other than that, your code looks good!

Jeff Wilkey
Jeff Wilkey
10,296 Points

Thanks for the quick reply Greg.