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 Strings

joning strings can't I do this let address = country + " " + state + " " + city?

can't I do this let address = country + " " + state + " " + city?

Bruce Röttgers
Bruce Röttgers
18,211 Points

You can, or what is the question?.

if your constant address has not been previously declared in your code you can do that perfectly, all you need to check that country, city and state are previously declared: let state = "im in a state" let city = "im in a city" let address = state + " " + city

1 Answer

Moritz Lang
Moritz Lang
25,909 Points

You could do this. However there is a cleaner way used throughout the Swift community:

let address = "\(country) \(state) \(city)"

This is called String interpolation, if you want to google it. :)