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 2.0 Basics Swift Types String Manipulation

XO Error
XO Error
877 Points

let name = "Sheldon" let greeting = "\("Hi there, ") \(name)\(".")" works fine in xcode but not here. Refuses to pass.

let name = "Sheldon" let greeting = "("Hi there, ") (name)(".")" Passes in xcode fine without error, but will not work here.

strings.swift
// Enter your code below
let name = "Sheldon"
let greeting = "\("Hi there,") \(name)\(".")"

3 Answers

So the second string you put together should look like this.

let greeting = ("Hi there, \(name).")

whenever you put () around something, that's calling the stored information you assigned to that variable to be used. you created a variable called "name" so you only need that around "name" to call that variable to be interpolated into your string. Interpolated is a big and confusing word so I like to think of it as adding something to the string without using a plus sign like you would in concatenation.

Hope this helps!!!

Yes there would, it cut that part out for some reason. Glad I was able to help!

XO Error
XO Error
877 Points

Thank you for the response it was helpful! Would there be a closed double quote at the very end?

XO Error
XO Error
877 Points

let greeting "Hi there, (name)." ended up working. Thanks!