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 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!