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

yusuf Dibswazit
yusuf Dibswazit
1,522 Points

what am i doing wrong??

func temperatureInFahrenheit(temperature: 30.2) { return temperature

}

functions.swift
// Enter your code below
func temperatureInFahrenheit(temperature: 30.2) {
  return temperature 

}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I'm not sure which step you're working on, but I don't even know where you got the 30.2 at all. I see no calculation for a conversion from Celsius to Fahrenheit either and there's nothing to denote the data type of the parameter or the data type for for the returned value. Here's my code for the final step along with some thought processes to reach the solution.

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

let fahrenheitTemp = temperatureInFahrenheit(24.0)
  1. Declare the function temperatureInFahrenheit to take a paramater of type Double and return a value with type Double
  2. Convert the temperature passed to it from Celsius to Fahrenheit
  3. Return the Fahrenheit temperature
  4. Create constant and call the conversion on a temperature
  5. return the Fahrenheit temperature into the new constant.

Hope that clarifies things!