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

Timothy Feltner
Timothy Feltner
556 Points

I cannot seem to find my error, I feel as though I entered the code properly

What did I do wrong?

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

1 Answer

Rodrigo Chousal
Rodrigo Chousal
16,009 Points

Hey Timothy,

When encapsulating strings, we surround the name of the string variable we're encapsulating with \( ). This means we are extracting the value of a variable and creating a larger string with it. What you're doing doesn't work because the compiler things "Hi there" and "Timothy" are variables, when in reality they're not. You should be passing in just the variable name to the greeting variable, like so:

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

Hope this helps, Rodrigo