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 Swift Types Recap: Swift Types

I don't know how to do interpolation for the step 2. Please help me Giovanni

I need help in string interpolation for the constant output. Thanks


// Enter your code below
let firstValue: Int = 4
let secondValue: Int = 6
let product = firstValue * secondValue

2 Answers

Chase Marchione
Chase Marchione
155,055 Points

Hi Giovanni,

We're told to create a constant called output. Since you've already made three constants, you know how to do that, so that's a good start!

The challenge asks us to make the output constant's value equal to a string containing something similar to 'The product of 2 times 4 is 8'--but instead of using those numbers, we need to use the constants that we just declared and initialized. We can print out the values of those constants through a process called interpolation, using the () syntax. Inside of the parentheses we would put the name of the particular variable/constant/etc.:

let output = "The product of \(firstValue) times \(secondValue) is \(product)"

Thus, given our constants' values, printing this out would produce "The product of 4 times 6 is 24."

Hope this helps!

I'll try it now. Thanks for your kind reply. I'm totally beginner in coding ?


it works, thanks ?????