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 Adding Power to Functions Returning Complex Values

Mark DeMItchell
Mark DeMItchell
1,527 Points

Having issues naming local parameter correctly.

Hi :)

Having a difficult time reconciling my code in this challenge to the error I keep receiving. Should I not be assigning an external and internal name in the argument and actually assign the local name as a var inside of the function?

Thanks for your help.

functions.swift
// Enter your code below
func coordinates(for location: String) -> (double,double) {


switch location {
   case "Eiffel Tower" : return (48.8582, 2.2945)
   case "Great Pyramid" : return (29.9792, 31.1344)
   case "Sydney Opera House" : return (33.8587, 151.2140)
   default : return (0, 0)
   }
   }

2 Answers

andren
andren
28,558 Points

The error messages generated by the challenge checker is often a bit misleading. Often it is more helpful to look at the error messages generated by the Swift compiler. Which you can see if you press the "Preview" button after an error has occurred.

The compiler error your code generates is this:

swift_lint.swift:6:44: error: use of undeclared type 'double'
func coordinates(for location: String) -> (double,double) {
                                           ^~~~~~

The error is informing you that it does not recognize double as a type. This is because you have forgotten to capitalize the D in Double. If you fix that typo like this:

func coordinates(for location: String) -> (Double,Double) {


switch location {
   case "Eiffel Tower" : return (48.8582, 2.2945)
   case "Great Pyramid" : return (29.9792, 31.1344)
   case "Sydney Opera House" : return (33.8587, 151.2140)
   default : return (0, 0)
   }
}

Then your code will work.

Alphonso Sensley II
Alphonso Sensley II
8,514 Points

Hello Mark DeMItchell, Looks like everything is correct! But because Double is a Type, it needs to be capitalized. In the tuple (double, double) Simply switch it to (Double, Double)

Hope that helps!