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

Tanner Shelton
seal-mask
.a{fill-rule:evenodd;}techdegree
Tanner Shelton
iOS Development Techdegree Student 1,136 Points

Why is fahrenheitTemp not returning my results?

func temperatureInFahrenheit(temperature: Double) -> Double {

    let fahrenheitTemp = (temperature * 9)/5 + 32
    return fahrenheitTemp

}

   let temperature = 24.0

Moderator edit: added Markdown so the code can be read in the Community. Please, when posting code, refer to the Markdown Cheatsheet located above the Post button

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Tanner,

It looks like you are trying to assign a value to the parameter instead of calling the function with a parameter passed in, as the instructions are stating. Remember when calling a function it is the function name with the parameter(s) passed into the parenthesis => functionName(parameter)

Have a look over the part of the code where you should be calling the function. The rest looks good! :thumbsup:

Keep Coding! :) :dizzy:

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Your last line: let temperature = 24.0 is trying to assign a hard-coded value to the variable, but the instructions specifically state to store the "return of the function call to the variable".
So, you need to call the function with the value of 24.0 passed in, and then store that into the variable named fahrenheitTemp not temperature:

let fahrenheitTemp = temperatureInFahrenheit(temperature: 24.0)