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 Function Scope

mrtroy
mrtroy
8,069 Points

backtick reserved keyword

Should I have used backticks to use the reserved keyword as a variable name as the description implies. It was the only way to solve this challenge.

5 Answers

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

I see what you mean. But when you write the code if you use for as the external name and then give it an internal name for this parameter there will be no error.

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

    }

}

Hope this helps

mrtroy
mrtroy
8,069 Points

Hey!

I would think that an implicit reference to a constant would fail just like an explicit one because you can't use "let for: String" with out an error. Thanks. It has been over a decade since I have done some real coding so I am getting back in the swing of things.

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Which code challenge are you referring to ?

mrtroy
mrtroy
8,069 Points

It is at the end of the Function challenge.

Declare a function named coordinates that takes a single parameter of type String, with an external name for, a local name of location, and returns a tuple containing two Double values (Note: You do not have to name the return values). For example, if I use your function and pass in the string "Eiffel Tower" as an argument, I should get (48.8582, 2.2945) as the value. If a string is passed in that doesn’t match the set above, return (0,0)

You can't use "for" as a name unless you backtick it. I tried "forLocation" which makes sense but the checker did not like that. I hope I am not giving any one an answer to the code challenge.

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Happy to help man, thats pretty awesome ! Was your previous languages you worked with Objective C ? What made you come back ?

mrtroy
mrtroy
8,069 Points

I worked at an internet company doing PERL and CGI for our customer portal and corporate intranet. I started back in the Basic days and worked with some exciting languages like Cobol and Fortran. Even some 8080A and 6809 machine language code that I had to hand convert hex code to base 10 to use the good old basic poke commands. Thats all old school. Been out of the loop for a while and want to get back in the AC. This heat is burning up this old computer geek.

Do you think there is a market for free lance coders with the horde of kids out there with lots of free time to code and play video games?

Jonathan Ruiz
Jonathan Ruiz
2,998 Points

Thats pretty awesome ! Im just getting started myself with programing actually. Im sure there is always something you can find I wouldn't worry to much about feeling like there isn't any jobs left or anything like that. I would say just to keep working on what you want to do and keep an eye out for opportunities you like