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 Functions and Optionals Parameters and Tuples Named Parameters

named_parameters challenge 2 confusion

Seem to be stumped again on a challenge. First I tried using the [ -> String ] but that didn't work either.

named_parameters.swift

1 let person = "Jerry" 2 func greeting(#person: String) { 3 return greeting(person: "Jerry") 4 }

named_parameters.swift
let person = "Jerry"
func greeting(#person: String) {
   return greeting(person: "Jerry")
 }

2 Answers

Vrund Patel
Vrund Patel
11,994 Points

Hope this helps.

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

thanks. It seems so logical now. I didn't realize I should keep the println command, although now I see it says to always add the code to what's already there. And rather than storing "Jerry" value as a constant you can eliminate code by calling it within the function. Just like the lesson was trying to point out. Duh!

Vrund Patel
Vrund Patel
11,994 Points

I am glad that it helped you.