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 Basics An Introduction to Swift Programming Working With Constants

why is this wrong? is the second quiz let constant = favoriteDessert var str = "cremebrulee"

let constant = favoriteDessert var str = "cremebrulee"


let constant = favoriteDessert
var str = "cremebrulee"

3 Answers

I have no idea what you are trying to do, but this is the solution:

let favoriteDessert = "cremebrulee"

As you see, you need the let keyword to tell Swift you are making a constant. Following the let keyword is a space and the variable name. Don't forget the space, for it's very important! Swift won't understand letfavoriteDessert. After that is an equal sign. The space before the equal sign is optional. The space after the equal sign is also optional. These spaces are optional, but it looks cleaner and easier-to-read with them. After the equal sign (or the optional space after the equal sign), is the value you want the variable to hold. We want to assign a string (a piece of text) to the variable.

To make a string, you simply wrap text around double quotes ".

Thank you Alexander. Guess I should see video again.

No problem :smile:

Can you please give a Best Answer so that this question is marked as Answered? Thank you. :smiley:


Thank you. Learning as I go.

I'm doing the tutorial for swift.