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: Operators Extra Credit Challenge

I was wondering if someone could help me. I'm trying to create a formular where you can change any given fahrenheit into celsius. I'm stuck because I am receiving an error every time.

Here is my code:

let degreesInFahrenheit = 70

let degreesInCelseus = (degreesInFahrenheit - 32) * 0.5556

2 Answers

Hi Riley,

I believe it is a type mismatch, one being an int and the other being a double.

Declare them both as type Double and this should resolve it for you, see code below.

let degreesInFahrenheit: Double = 70

let degreesInCelseus: Double = (degreesInFahrenheit - 32) * 0.5556

Thank you Lee!

Thanks for giving me a good answer; it worked! If your following this question, could you please tell me if I have done this the best way possible? Or is there an even better way to do this?

Hi Riley,

I think the answer is about right in terms of efficiency, but someone with a bit more experience than me may be able to give you a better solution.

Cheers

Lee