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 Functions in Swift Functions in Swift Recap: Functions

Arius Eich
Arius Eich
2,769 Points

Whats wrong? Functions

I'm sure I'm doing something really simple incorrect but what is it?

functions.swift
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
     (((temperature * 9) / 5 ) + 32)
    return(temperature)
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Arius,

Yep... you've got all the pieces there, but just a bit too much and in the wrong place.

The task wants you to return the new value, which is done after the math. You do have the equation there, but it needs to be inside of the return statement. Right now, the way you have it, the compiler just sees a random line that really does nothing, as it is not 'assigned' to a variable or returned to one. Also, while your equation is 'technically' correct, you do not need all those parenthesis. The rules of Mathematics will do the equation in the proper order as it is written here.

So, all you need to do is to move the entire line with the equation inside of the return and remove those extra/unneeded parenthesis (but keep the one around the return statement)

This should get you going, but let me know if you're still stuck.

Keep Coding! :) :dizzy: