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

i need halp on this

i don't know how to do dis

temperature = 2.0
func temperatureInFahrenheit(temperature){

1 Answer

Alex Millius
Alex Millius
iOS Development Techdegree Student 5,468 Points

It may be confusing since the result of the first part of this challenge doesn't do anything.

Let's take the description of the challenge part by part.

  1. "Declare a function named temperatureInFahrenheit." -> you have to declare a function, not a variable or a constant:

func temperatureInFahrenheit(){ }

  1. "The function should take a single input named temperature" -> temperature is the name of the input parameter, not of a variable or a constant. the input are in parentheses:

func temperatureInFahrenheit(temperature ){ }

  1. " of type Double" -> you have to specify the type of your parameter, in this case, Double:

func temperatureInFahrenheit(temperature : Double){ }

  1. " and has a return type of Double." -> your function return something, in this case a Double:

func temperatureInFahrenheit(temperature : Double) -> Double { }

  1. "For now, to make the function pass, simply return the value of the temperature parameter from the function." -> you have to return the function parameter, which is temperature. Since temperature is a Double, it correspond to your return type:

func temperatureInFahrenheit(temperature : Double) -> Double { return temperature }