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

Swift Parametres and Tuples

Hey guys! What I'm doing wrong whit my code..

Challenge task 2 of 2 Call the greeting function and pass it the String "Jerry"

func greeting(#person: String) { greeting(person: "Jerry") }

Bummer! You need to call 'greeting()'

5 Answers

Ok, first, what you have discovered is recursion, thus calling a function again from within. But, this is not what you have to do here.

func greeting(#person: String) { // your code to print the string }

greeting(person: "Jerry")

Your code should look like this:

func greeting(#person: String) {
println("Hello \(person)")}

greeting(person: "Jerry")

Thanks man, yeah my external parameter was throwing me off.

Thanks!

I get the first part of this of calling an external parameter as you are defining an external parameter called person but the second part I'm not understanding. I don't get the need to have the code to print the string? I'm stuck on what it is asking for? I understand the greeting(person:"Jerry") as you are calling the greeting function. func greeting(person greeting: String) {

Ok so right now I have this func greeting(person greeting: String) { println("person") greeting(person: "Jerry") } Still trying to figure out what it wants or what I'm missing.

I think you're trying to make more of the challenge than what it's actually asking of you. You also need to add the label name to the parameter (in the parenthesis). Mind your placement of the brackets, too :-)

Your code should look like this:

func greeting(#person: String) {
  println("Hello \(person)")}

greeting(person: "Jerry")