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

Christopher Martin
Christopher Martin
480 Points

My code for the "println" challenge worked in the playground, but not in the challenge box on treehouse. Why not?

Here's the code:

let language: String = "Swift" println("Learn " + language)

What did I do wrong?

Christopher Martin
Christopher Martin
480 Points

I put a line break between "Swift" and println, by the way.

Michael Pastran
Michael Pastran
4,727 Points

the code should look like this

let language = "Swift" println("Learn (language)")

the reason is that you are trying to use string concatenation ( + ). but what you need is interpolation because you are putting a variable inside of string.

Michael Pastran
Michael Pastran
4,727 Points

also make sure they are not asking you to tell it the data type. try it without the String. the code is right but they might not be asking for it to be put that way. let me know if it works lol

Christopher Martin
Christopher Martin
480 Points

Thank you so much Michael! Your answer really helped me.

Michael Pastran
Michael Pastran
4,727 Points

yeah no problem. idk why its not showing the " \" before (language) on my comment. if you have any more questions feel free to ask.

Christopher Martin
Christopher Martin
480 Points

Yup, I watched the video again and used the (language), and it worked :)

1 Answer

Dear Christopher Martin,

To print that line, you need to use String Interpolation. To use that, you must do the following:

let language: String = "Swift"; println("Learn \(language)")

You can also move the print statement underneath and delete the semicolon.