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!

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 (retired) Variables and Constants Constants

Create a constant named language and assign it a string "Swift"

how do i solve the question

var str = "Swift"
Riley Spencer
Riley Spencer
1,753 Points

You've made two mistakes here

First, you have created a variable (using var), instead of an constant. To create a constant, replace the var with let.

Second, you have called it str. You should be calling it language.

2 Answers

You are on the right track you need to use let to declare a constant variable...

                          let language = "Swift"
Bao Pham
Bao Pham
Courses Plus Student 240 Points

I just passed the first session as of now. I didn't understand it at first when I attempted to write the string because of simply the site does not behave exactly like the program "Xcode". I am not giving you the answer here, but when you are supposed to declare the string in reference to "Implicit types" the site does not automatically capitalize the declaration as the system running Xcode does. Had me scratching my head quite a bit haha.


Basically when writing a string you learned at first to write "var" indicating the word (Or terms, abbreviations,etc.) after is the variable. Now, modifying the string line into a "Constant" would be using "let" instead.