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
Anthia Tillbury
3,388 PointsSwift: String Manipulation (Basics)
The following code will complete the second challenge for String Manipulation, but I found a workaround for adding an Integer to a String Literal via the Concatenation method:
let name = "Steven."
let greeting = "Hi there, \(name)"
let finalGreeting = (greeting) + " How are you?"
If changing "name" to an integer the "finalGreeting" Concatenation will include the Integer, believing it to be a String Literal!
let name = 222
let greeting = "Hi there, \(name)"
let finalGreeting = (greeting) + " How are you?"
Martin Wildfeuer
Courses Plus Student 11,071 PointsMartin Wildfeuer
Courses Plus Student 11,071 PointsThat is expected behavior and actually why String interpolation is such a handy thing: The values wrapped in
\()will be converted to a String from any type, it does not have to be a String. From the Apple docs example: