Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

150,854 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 ?????