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

Christopher Tavarez
Christopher Tavarez
299 Points

Not sure why My greeting Variable is not working

so far I have gotten it to work on xcode but not on the challenge task

Christopher Tavarez
Christopher Tavarez
299 Points

Thank you so much I figured out that much I am new at coding in general and wanted to start with swift right now I am having problems with print and println and this task I have posted. I cant seem to grasp what the interpolation is trying to do

Given the constant named language, write a println statement which will print the following string: "Learning Swift".

Use the language constant within the string you pass to your println statement. Practice using string interpolation.

1 Answer

Hi Christopher,

As of Swift 2, the println function is no longer available and the print function should be used instead. That said, the online code editor for the challenges is still expecting the use of println. If you are using the latest version of Xcode, you will have to use the print function in the playground (use of println will give an error). For the online challenges you will have to use println until Treehouse makes the necessary updates.

As for string interpolation: It basically allows you to substitute the current value of a constant or variable within string.

For example:

var firstName = "John"
var greeting = "Hello \(firstName)"
print(greeting)

The above code would output "Hello John".

Without string interpolation, you would have to do the following:

var firstName = "John"
var greeting = "Hello " + "firstName"
print(greeting)

You would still get the same result, but string interpolation makes strings easier to format and your code easier to read.

Hope this helps.

-- Ryan