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 trialMichele Livingston
iOS Development Techdegree Student 808 PointsHow do you add a type double?
The question ask to make temperature of type double. What does that mean in the code.
// Enter your code below
func temperatureInFahherinheit (temperature: Int) {
=
return temperature
}
2 Answers
andren
28,558 PointsDouble is a type of value, like Int and String. It is used for storing numbers with decimal values like 3,14 or 532,2532, etc. The Int value type is only used to store whole number without decimals like 5 or 6324, etc.
So "in code" it means that you have to declare the temperature variable as type Double not Int, you also need to declare the return type as Double. It also seems you have a typo in the name of your function that you'll need to fix before you can continue to the next task.
Daniel Walker
2,031 Pointsso you have :
// Enter your code below
func temperatureInFahherinheit (temperature: Int) {
=
return temperature
}
you should make it more like this if your looking for an answer with a decimal point.
// Enter your code below
func temperatureInFahherinheit (temperature: Double) -> Double {
=
return temperature
}
Michele Livingston
iOS Development Techdegree Student 808 PointsMichele Livingston
iOS Development Techdegree Student 808 Pointshow do you declare the return type as double
andren
28,558 Pointsandren
28,558 PointsIn the same way you declare it for other types, like this:
The "-> Double" part of that example function is specifically where I define the return type, did you accidentally skip the video that preceded this challenge? The Return Types video introduces the concept of return types, and shows off how they work.