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.

Raza Dar
iOS Development with Swift Techdegree Student 108 PointsString Concatenation is letting me compile building number & the Street! Is it a bug or a new feature?
let streetAddress = buildingNumber + street Result: "222Khalidia Street"
2 Answers

Caleb Kleveter
Treehouse Moderator 37,862 PointsMy guess is that you declared the buildingNumber
variable differently from the way Pasan did it. In the video, the code looks like this:
let street = "West Street"
let buildingNumber = 222
let streetAddress = buildingNumber + street
This code does not compile because street
and buildingAddress
are different types. Basically you have text and a number and Swift doesn't know how those should be added together.
My guess is that when you created the buildingNumber
constant, you placed quotes around the number:
let buildingNumber = "222"
This would make it so the street
and buildingNumber
values can be added together because the buildingNumber
is a String
instead of a number.
Hope that sorts it out for you!

Chron Chern
314 PointsThanks for posting and answering this question! Helped a lot!