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 Basics Swift Types Strings

Riley Cooper
Riley Cooper
1,649 Points

Country + State + City

Hi. Its not a huge deal, but I feel its important to understand every single step. When I do the part where we say:

let address = country + ", " state + ", " + city

I get an error for some reason. Consecutive statements on a line must be seperated by ';'

What have I done wrong? I feel like I've followed our glorious professor step by step.

Thank you in advance! -Riley

1 Answer

andren
andren
28,558 Points

You are simply missing a +, specifically it's missing before the state variable. When concatenating multiple strings and variables like that it is very easy to accidentally leave a + off. It's a pretty common error, but one that will lead to a crash.

For that reason there are a number of people who prefer to use string interpolation instead when combining many variables and strings together. As not only is it arguably cleaner and faster to type, but it makes mistakes like that easier to avoid.

Riley Cooper
Riley Cooper
1,649 Points

Thank you so much for explaining it. That seems obvious now, but at the time I couldn't figure it out. Thanks again.