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) Control Flow For-In Loop

Dan S
Dan S
1,166 Points

In the example, for number in 1..<10 { println("\(number) times 2 is \(number*2)") what does backslash mean?

I am just wondering what the backslash means? I don't recall learning what the backslash does in the println function. Could you please explain what it does? Thanks.

2 Answers

Kevin Hamil
Kevin Hamil
8,203 Points

It's called String Interpolation. The slash just tells the compiler that you're inserting a variable in your print string and it should use the variable's value. Must be used with the parenthesis.

Dan S
Dan S
1,166 Points

Thank you! I got it now!