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 trialMarie Jose Lemiere
872 PointsString is not convertible to String
I get the message : "String' is not convertible to 'String'" I can't find a way around...
func greeting(person: String) -> String {
return greeting
}
1 Answer
Pedro Ruíz
28,105 PointsThe problem here is you're trying to return the function name as a string, so the compiler is getting into an endless circular loop. Just changing the return statement to anything else should work as in the example provided next:
func greeting(person: String) -> String {
return "Hello " + person
}
greeting("Pedro")
Marie Jose Lemiere
872 PointsMarie Jose Lemiere
872 PointsThank you Pedro ! It helps me a lot.