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 Functions in Swift Functions in Swift Recap: Functions

Michele Livingston
seal-mask
.a{fill-rule:evenodd;}techdegree
Michele Livingston
iOS Development Techdegree Student 808 Points

How do you add a type double?

The question ask to make temperature of type double. What does that mean in the code.

functions.swift
// Enter your code below
func temperatureInFahherinheit (temperature: Int) {
     = 
    return temperature
}

2 Answers

andren
andren
28,558 Points

Double 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.

andren
andren
28,558 Points

In the same way you declare it for other types, like this:

func exampleFunction (value: Double) -> Double {
}

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.

Daniel Walker
Daniel Walker
2,031 Points

so 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
}