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

Swift types

let firstValue = 1 let secondValue = 2 let product = "firstValue*secondValue" let firstValue = 2 let secondValue = 4 let product = "firstValue*secondValue"

need some helps

types.swift
// Enter your code below
let firstValue = 1
let secondValue = 2
let product = "firstValue*secondValue"
let firstValue = 2
let secondValue = 4
let product = "firstValue*secondValue"

2 Answers

Apoorva S
Apoorva S
998 Points

That error message on the following lines, let firstValue = 2 let secondValue = 4 let product = "firstValue*secondValue"

means that you have created two variable with the same name. That is,

let firstValue = 1 let firstValue = 2

Points to observe:

  1. firstValue, secondValue, product have been declared as let; constant, wherein the value cannot be changed. incase you want to change the value (firstValue = 2, secondValue = 4, product = "firstValue*secondValue") change let to var.

    var firstValue = 1 var secondValue = 2 var product = firstValue*secondValue

  2. Don't redeclare firstValue, secondValue, product. Simply use it as

    firstValue = 2 secondValue = 4 product = firstValue*secondValue

which will allow you to assign new value and perform multiplication.

lastly: let product = "firstValue*secondValue" The above line will not perform multiplication - "firstValue*secondValue" This is just a string which is assigned to 'product' variable.

thanks