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

Sophie Barton
PLUS
Sophie Barton
Courses Plus Student 117 Points

Hi There, I'm confused as to why this isn't working? let name = "Sophie." let greeting = "\(Hi there) \(name.)"

Looks like I'm missing something. I've watched to video a couple of times and still unsure.

Mant thanks

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

2 Answers

Abdallah Nofal
Abdallah Nofal
4,020 Points

You don't have to add "Hi there " inside "()" It's only used when you try to add another variable inside string so you add the variable or the constant inside it.

Like in your example: you create const called name let name = "Sophie." after that you want to create another const for greetings so you'll write it like that let greetings = "Hi there Sophie." now you can replace "Sophie." with first const you created it but you want to tell the compiler that "name" is a const not a normal string so you'll have to add it inside "()"

so it will be let greetings = "Hi there (name)"