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

akin kuelhanbey
akin kuelhanbey
7,474 Points

Where can I get the solution for the challenge? I wasn't able to solve it.

Can someone help me to find out the solution, please? I would much appreciate it if you guys from team Treehouse would add also the solutions for that challenges. Thanks a million in advance.

best ak

strings.swift
// Enter your code below
let name = "akin"

let greeting = "Hi there ," + "\(name)."

5 Answers

Hi there,

You want to use string interpolation to include the variable in the string:

let name = "Steve"
let greeting = "Hi there, \(name)"

Make sense?

Steve.

And the final part of this challenge has a little bug in it - make sure you omit the space at the start of the suggested string - it should look like:

let finalGreeting = greeting + "How are you?" // no leading space before " How ... 

Steve.

You beat me to it! Sorry for the double answer haha

:-)

Can't have too much help!

Task 1a: Declare a constant named "name" and assign a string with your name.

let name = "Ian"

Task 1b: Declare a constant named "greeting"

let greeting = 

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

let greeting = "Hi there, \(name)."

Interpolated is the key word there, not concatenated. So you don't need the "+". You'll do that in the next task.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Don't use concatenation, only use interpolation.

let name = "akin"

let greeting = "Hi there ,\(name)."
akin kuelhanbey
akin kuelhanbey
7,474 Points

Thank you very much for all your help, guys! Much appreciated. :)