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 trialKyle DuFrene
4,217 PointsWhat am I doing wrong here?
Here is the question: "Letβs assume we want to create a model to represent a box of chocolates. The chocolate box will contain dictionary instances that stores information about different kinds of chocolates. To start, create a struct named ChocolateBox." I am not sure what I am doing wrong or if I am completely doing the wrong thing. Thanks!
struct ChocolateBox {
let carmelDelight: String = [["flavor": "caramel"]]
}
3 Answers
Chris Stromberg
Courses Plus Student 13,389 Points// First part of challenge just make the struct
struct ChocolateBox {}
// For the second part of challenge you need to add a dictionary (Key Value paring).
struct ChocolateBox {
var caramelDelight = ["flavor": "caramel"]
}
// In your code the syntax was wrong. You told the compiler that you were creating a String
// when you were actually creating a Dictionary. You also had some extra brackets.
let carmelDelight: String = [["flavor": "caramel"]]
Kyle DuFrene
4,217 PointsThanks!
Caleb Kleveter
Treehouse Moderator 37,862 PointsYou don't need to specify a string, and I'm not sure if you need to change it to a variable but you only need one set of brackets, not two.
var carmelDelight = ["flavor": "caramel"]
Kamil Wrobel
5,546 Pointsthis works, it just have a typo instead of "carmelDelight", you need to write "caramelDelight"