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 (retired) Operators Binary Operators

Srinivasan Senthil
Srinivasan Senthil
2,266 Points

let areainmeters = area / 10.764 This is not returning the integer value. First example in the binary operator lesson.

In the binary operator lesson, Amit said that this operation will return an integer type, since the value defined for height and width are integer typer. The height and width are used for caluclating the area. The are is then divided by 10.76 to yield the answer in SQ meters.

Only if use double then it works. Like: let areainmeters = Double(area) / 10.764

3 Answers

Ryan Schumacher
Ryan Schumacher
1,907 Points

It will not return an integer value because 10.76 is a double, the return will be a double.

Srinivasan Senthil
Srinivasan Senthil
2,266 Points

Ya Ryan, but it worked in the video. Thats why i'm confused.

Joakim Skansen Flatmoen
PLUS
Joakim Skansen Flatmoen
Courses Plus Student 24,223 Points

I think the result you experienced in the video is not working due to an update from Apple, so it do not accept that syntax any more.

in case to get it working you can do two things. 1: Store the let/var as a Double like this: let foo = 21.0 2: make swift read the integer as a Duble, like this: Double(House) * 12.764