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 (retired) Types Printing Results

Why use interpolation?

Lets say I defined a variable combination as "Hello". What is the difference between printing the variable in these two ways? Is it the same thing but written in different ways or is there an advantage in using one over another?



1 Answer

Interpolation allows you to easily print out a string which maybe contains more than one variable as well and some additional text which you are inputting into the actual print method itself.

You can also concatenate the strings and variables to achieve the same thing but often if interpolation is available it will be a lot easier to read and look nicer in your code.