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

Les Gaw
Les Gaw
4,752 Points

Not sure why this second part did not work ?

I am not sure why the code did not work when i tried it as it appeared to work in Xcode?

strings.swift
// Enter your code below
let name = "Pasan"
let greeting = "\("Hi there,") \(name) \(".")"
let finalGreeting = "\(greeting) \(" How are you?")"

3 Answers

You don't need () for text inside of strings (although it is possible to use it and you still would be able to pass the challenge, the code would be hard to understand and fix). You only need it for variables/constants :)

Try this:

// Enter your code below
let name = "Pasan"
let greeting = "Hi there, \(name)."
let finalGreeting = "\(greeting) How are you?"

Also, you have an extra space before the period (code challenges are super picky, keep that in mind :smile:)

Good luck! ~Alex

Les Gaw
Les Gaw
4,752 Points

Thanks Alexander - that has made it clearer for me in terms of not having to use additional quotations and () for text. However, using it in the code challenge the second part still shows an error! I am convinced i have typed this word for word and i know that it works in Xcode as per what you types. Thanks for your help though.

What's the error?

Les Gaw
Les Gaw
4,752 Points

The error is "Make sure you're using concatenation to create the final string value required!"

Try changing the period to a comma :)

~alex

Les Gaw
Les Gaw
4,752 Points

it turns out i messed up as i should have used string concatenation in the last part rather than just having a single string. Passed the test now. Thanks for your help

No problem :)