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 (retired) Types Printing Results

how do I write a println statement which will print the following string: "Learning Swift" ?

I need the steps

3 Answers

Chris Jones
STAFF
Chris Jones
Treehouse Guest Teacher

Brandon J's answer is incorrect. You need to use a backslash for string interpolation and not a forward slash. Also, the variable needs to be within the string.

I didn't give an answer because I was hoping Caden Smith would watch the video again as the answer would have been very easy to find on his own. However, since it's now been confused with a wrong answer, the correct syntax is below.

let language = "Swift"
println("Learning \(language)")

So, instead of just writing println("Learning Swift"), you are using the string stored in the constant language. Another example:

let firstWord = "Learning"
let language = "Swift"
println("\(firstWord) \(language)")

The result would be the same "Learning Swift"

Chris Jones
STAFF
Chris Jones
Treehouse Guest Teacher

Might I suggest just watching the video over again? That's all it should take for you to find the answer.

I dont understand how to set the information I have up in the println statement

Chris Jones
Chris Jones
Treehouse Guest Teacher

Go back and watch the Printing Results video. Around 4:45 into the video, is exactly where it talks about using println() and string interpolation which is what you need to know for the code challenge at the end of the video.

Well Im sure this will help. I also had trouble in that one to. Code: let language = "Swift" println("Learning "/(language))