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 trialIsaac Ballas
1,105 PointsWhat is wrong with my code here
I cannot understand what I did wrong
func temperatureInFahrenheit(temperature: Double) {
return temperature: Double
}
2 Answers
andren
28,558 PointsYou are defining the return type incorrectly. Specifying the type of an existing value like you are doing in your return statement is incorrect. The way you specify return types in swift is by using an arrow -> between the parenthesis and the body of the function where you specify the type, like this:
func temperatureInFahrenheit(temperature: Double) -> Double { // The "-> Double" tells Swift the return type
return temperature
}
Matt Buckingham
11,389 PointsWhen returning a value in a function you must add the -> Type after the parameters! And you only have to use temperature: Double in the parameters! Just return temperature!
func temperatureInFahrenheit(temperature: Double) -> Double {
return temperature
}