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 Build a Playlist Browser with Swift Building the Music Library and Playlist Models Creating a Data Model

Abraham Zamudio
Abraham Zamudio
1,896 Points

Structs

I need help on this problem (We need to add the first chocolate to our box. Create a stored property named caramelDelight. To this dictionary add a key named flavor that stores a value named caramel to the caramelDelight dictionary to initialize it.)

ChocolateBox.swift
struct ChocolateBox {
}

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Abraham,

First, we will create the caramelDelight stored property by declaring it using 'var'. Next up, we need a key named flavor, with a corresponding value named caramel, so that we can initialize the caramelDelight dictionary as asked. The syntax for adding key-value pairs is ["key": "value"].

  var caramelDelight = ["flavor": "caramel"]

Hope this helps!