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

Rayhan Miah
Rayhan Miah
2,369 Points

Declare constant named product the multiply how do i do that

How do i compile it whats the code

types.swift
// Enter your code below
let firstValue: Int = 2000000000000
let secondValue: Int = 300000000000


let product = firstValue * secondValue



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

2 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Rayhan,

Your code is perfect. There's a bug in the challenge. If you reduce the size of your integers to something like 2000 and 3000, you'll be all set.

Pasan Premaratne, it would be good to have an error message if the integers are too large. I assume there's some character limit in the string the back-end is checking - maybe that could be added to the validation?

Cheers :beers:

-Greg

Pasan Premaratne
Pasan Premaratne
Treehouse Teacher

There isn't a bug here. Run the code in a Playground and you'll get a crash as well. This is known as an overflow error.

Greg Kaleka
Greg Kaleka
39,021 Points

Oh man - I didn't even think of that. 2000000000000 * 300000000000 = too big for an Int - got it.

Rayhan Miah
Rayhan Miah
2,369 Points

Thank you it worked