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

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