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 trialHilton Weeks
285 Pointswith interpolation , how would i print if i wanted to use the variable or constant first.
example if my variable was Alice. Example Var = "Alice" , and i wanted to print "Alice says Hi". How would i go about that/
2 Answers
Steve Hunter
57,712 PointsSay,
var name = "Alice"
Then,
"\(name) says Hi!"
should give you what you want?
Steve.
Marcio Mello
7,861 PointsI believe it would go like this:
var name = "Alice"
println(" (name) says Hi!")
EDIT: Well, someone replied at the same time as me ;)
Steve Hunter
57,712 PointsYou need a backslash before the brackets, I think.
Steve.
Marcio Mello
7,861 PointsYou are right Steve, my bad. Forgot to add it. Thanks.
EDIT: Actually I did, but for some reason it doesnt display. I wonder why?