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

I solved the challenge in a different way than they asked, and while it is different the outcome is the same.

let height = 120.0 // in inches let width = 144.0 // in inches

let area = height * width

let areaInFeet = area / 12

area.swift
// the height and width of a wall
let height = 120.0 // in inches
let width = 144.0 // in inches

let area = height * width

let areaInFeet = area / 12

1 Answer

Mac Bellingrath
Mac Bellingrath
13,502 Points

You're right, the output was effectively the same. It is "swift" in nature to be as concise as possible. If you can perform both operations in one line of code rather than to establish an additional variable, your code will be more readable. In more complex cases, however, you might write a helper method that could handle complex operations and simple call them when needed. Happy Swifting!

Thanks! It's just frustrating that this is literally the way the video taught, and the challenge is asking for something else.

Mac Bellingrath
Mac Bellingrath
13,502 Points

It can be frustrating. Think about it like this, running into challenges like this is how you'll become a better developer! The best developers don't just follow instructions, they are capable of solving problems. You can do it.