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
Alex Bargar
760 PointsSwift Basics: Collections. Extra Credit Please Help?
The extra credit prompt is "Create an array of 10 songs where each song is a dictionary. The dictionary contains the following keys: title, artist and album."
I can't figure at all how to put dictionaries inside an array. Can anyone please help?
1 Answer
Vittorio Somaschini
33,371 PointsHello Alex.
Reading your question I presume you know how to create the dictionaries right?
Technically you only need to separate the dictionaries with a comma and surround all the dictionaries with [] representing the array.
Something like this should do:
var dictionaryArray = [ ["ke1" : "value1", "key2" : "value2"], ["ke1" : "value1", "key2" : "value2"] ]
Vittorio