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

Amir Amiri
PLUS
Amir Amiri
Courses Plus Student 102 Points

Could you please explain the answer of this challenge

This is how I wrote this:

let language = "Swift" var Amir : String = "Learning" println(amir+language)

I don't know why it's not working !!!

println.swift
let language = "Swift"
var Amir : String = "Learning"
println(Amir+language)
Shubham Batra
Shubham Batra
1,960 Points

The problem is in the last line. It should be:

println(Amir + language)

There should be a space before and after the plus operator

Amir Amiri
Amir Amiri
Courses Plus Student 102 Points

Actually I did and this is the error again: You need to interpolate the value of the 'language' constant into the string you pass to 'println'.

1 Answer

Holger Liesegang
Holger Liesegang
50,595 Points

Welcome to Treehouse, Amir Amiri !

The error message said: "You need to interpolate the value of the 'language' constant into the string you pass to 'println'."

You can do that like this:

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

...also you might want to have a look at https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html at section String "Interpolation"