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

println does not work: why? not in Xcode either. let language = "Swift" println("Learning",language)

Using Treehouse course "iOS, i have problems:

println does not work: why? not in Xcode either.

let language = "Swift" println("Learning",language) // should say "Learning Swift" // doesn't

// above is Treehouse Teacher // below is Xcode, on mac

let language = "Swift" // shows: "Swift\n" print(language) // shows: "Swift\n" print("Learning",language) //shows: "Learning Swift\n" println("Learning",language) //shows: ERROR 'println' has been renamed to'print"

So, println is NOT right?

Is there no way to use this course? or is there something useful online?

\Thanks, Shelli

println.swift
let language = "Swift"

println("Learning",language)

2 Answers

Steven Deutsch
Steven Deutsch
21,046 Points

Hey shelli howell,

You need to use String Interpolation to add the value associated with the variable into the string literal. You do this by writing \() and placing the variable name inside of the parentheses.

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

Good Luck!

Mazen Halawi
Mazen Halawi
7,806 Points

in Swift 2.0 the println has been renamed to print. when you use print() xcode will print whatever you add in between the parenthesis and finishes up with a new line "\n" so if you do:

print("Swift Course") the result will be Swift Course\n