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"

I

constants.swift
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:

~Alex

Thank you. Learning as I go.

I'm doing the tutorial for swift.