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

Rayhan Miah
Rayhan Miah
2,369 Points

Whats wrong with this code

let name = "Rayhan" let greeting = "Hi there," let interpolatedGreeting = "(greeting) (name)"

whats wrong with it

strings.swift
// Enter your code below
let name = "Rayhan"
let greeting = "Hi there,"
let interpolatedGreeting = "\(greeting) \(name)"
Ben Masel
Ben Masel
2,004 Points

If it still doesn't work i know why, if that happens just comment on this page i and i will help!

2 Answers

Greg Kaleka
Greg Kaleka
39,019 Points

Hi Rayhan,

You're coding correctly, but you should re-read the instructions :smiley:.

The first task asks you to

Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.

So in your case, you need to interpolate your name right in the greeting string so that greeting stores "Hi there, Rayhan."

Given the code you've written, I'm sure you know how to do this!

Cheers :beers:

-Greg

Rayhan Miah
Rayhan Miah
2,369 Points

WOW thank you it worked

Ben Masel
Ben Masel
2,004 Points

Hi there Rayhan! All you forgot to do was concatenate interpolatedGreeting so interpolatedGreeting should really look like this:

let interpolatedGreeting = "(greeting)." + "How are you?"

hope this helps!