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 trialUnsubscribed User
903 PointsSwift
How come you don't put everything in parentheses? Someone please explain. Thank you.
1 Answer
Steve Hunter
57,712 PointsHI Maged,
I'm not sure what you are asking here?
The brackets used in this question are for string interpolation. This allows you to add the contents of a variable (or constant) into a string. The quiz here uses this when creating the output
string like this:
let firstValue = 10
let secondValue = 20
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
In place of \(firstValue)
, the string will contain the value of firstValue
which is 10 in this case. The same with the other two constant names.
I hope that helps - if not, let me know what it is that's confusing you and I'll get back to you.
Steve.