Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.