
Zulfikhar Fikar
3,900 Pointswhat i have to do, when i wrote the code in FahrenhaitTemp, its getting error
this is the code that i have been written:
func temperatureInFahrenheit (temperature: Double) -> Double { return ((temperature*9)/5) + 32 }
let fahrenheitTemp = temperatureInFahrenheit (24.0)
but ya..bummer, please help me, thanks
func temperatureInFahrenheit(temperature: Double) -> Double {
let fahrenheit = (temperature * 9 / 5) + 32
return fahrenheit
}
let fahrenheitTemp = temperatureInFahrenheit(24.0)
1 Answer

andren
28,391 PointsIn situations where your code does not work for mysterious reasons it can often be a good idea to look at the compiler errors that Swift generates. They are often more informative than you might expect. To see them just click the "Preview" button after an error has occurred.
For your code the compiler error generated is this:
swift_lint.swift:12:46: error: missing argument label 'temperature:' in call
let fahrenheitTemp = temperatureInFahrenheit(24.0)
^
temperature:
That error message not only point out what is wrong but practically tells you what to do to fix it. You forgot to write the label for the argument so all you have to do is add it like this:
let fahrenheitTemp = temperatureInFahrenheit(temperature: 24.0)
And then your code will work.