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

Some help

How do I go about this

types.swift
// Enter your code below
let firstValue = 23
let secondValue = 32
let product = (23*32)

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,859 Points

Hi Gerald,

The question tells you:

Declare a constant named product and assign the result of multiplying firstValue and secondValue together.

You have multiplied two number literals together (23 and 32) and haven't used firstValue or secondValue.

Cheers

Alex

William Li
PLUS
William Li
Courses Plus Student 26,857 Points

hmmm ... I was asked to answer this question.

As Alex has pointed out, you shouldn't perform the multiplication on the two raw numerical values, replace 'em w/ the two constants instead. On top of that, it's unnecessary to put the parenthesis () around them. Parenthesis is used in the case when you need to change the operator precedence in the calculation. e.g. (3+2) * (5+2), in this case, the parenthesis is necessary because you want to force the addition to be performed before the multiplication, otherwise just leave the parenthesis out when it's not needed. In Swift, parenthesis happens to be also a language construct for creating a data structure, putting the extra parenthesis in the code that doesn't need to be there would only create visual noise for the reader of the code.

Also, Part 2 of the challenge has TWO steps, don't forget to complete the step 2 of creating a string literal to pass the challenge.

happy coding.