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 (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