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

aren polat
aren polat
883 Points

types

could some one give the last outputs answer please

types.swift
// Enter your code below
let firstValue: Int = 32
let secondValue: Int = 24
let product = "firstValue * secondValue"
let output = "

1 Answer

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Hi aren, in your product constant you had imputed a string but it wants you to just multiply the firstValue and secondValue. You would have to use string concatenation where you call the names of the constants and use an assignment operator to multiply them together.

let product = firstValue * secondValue

The second part is your output, this is the one that they want you to use string interpolation for.

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

// this prints "The product of 32 times 24 is 768"

// when using string interpolation you have regular string values then you can call on a constant or variable 
// to call on a let or a var you use the syntax \(randomConstant)  
// with a backslash then putting the constant or variable in parenthesis you can use string interpolation to get what the question asks for 

Hope this helps