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

Concatenated

/Users/mattconway/Desktop/Screen Shot 2016-01-07 at 10.24.15 AM.png

What in the world am I doing wrong?

strings.swift
// Enter your code below
let name = "Matt"
let greeting = "Hi there"

let interpolatedgreeting = "\(greeting), \(name)."

let finalGreeting = "How are you?"

let concatenatedfinalGreeting = greeting + ", " + name + ". " + finalgreeting + "?"

2 Answers

Thanks for your help. I still have some learning to do, still not quite used to it .......

Michael Reining
Michael Reining
10,101 Points

Hi Matt,

Combining the strings can be done a bit simpler which is what the code challenge is looking for in terms of an answer.

For part 1, all you needed is this.

let name = "Matt"
let greeting = "Hi there, \(name)." 
// there is no need for two interpolated strings like in your example

For part 2, just combine the greeting constant with the new string like this.

let name = "Matt"
let greeting = "Hi there, \(name)."
let finalGreeting = greeting + "How are you?"

I hope that helps,

Mike

PS: Thanks to the awesome resources on Team Treehouse, I launched my first app.

Now you can practice writing Swift code directly on your iPhone :-)

Code! Learn how to program with Swift