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

Value

Not sure what value to put in the let statement

Challenge Task 1 of 3

Declare a function named temperatureInFahrenheit. The function should take a single input named temperature of type Double and has a return type of Double.

For now, to make the function pass, simply return the value of the temperature parameter from the function. In the next task, we'll add more code to the body.

/Users/mattconway/Desktop/Screen Shot 2016-01-16 at 1.08.00 PM.png

functions.swift
// Enter your code below
func temperatureInFahrenheit(temperature: Double) {
let temperature = 
return temperature
}

4 Answers

Still not clear ... can you give me an example

/Users/mattconway/Desktop/Screen Shot 2016-01-16 at 1.42.22 PM.png

Emil Rais
Emil Rais
26,873 Points

You should return the value of temperature, almost in the way you attempted. The "let =" does not belong there as that is used for storing values in constants; and here you should simply return the value. Also you need to specify the return type of the function.

Emil Rais
Emil Rais
26,873 Points
func someFunctionName(/* This is where you place parameters */) -> /* This is where you place the return type if any */ {
  return /* You can return some value here */
}

func wordInEnglish(word: String) -> String {
  return word
}

ok got it, thanks.

Emil Rais
Emil Rais
26,873 Points

Glad to hear it; happy coding!