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 trialHenry Gilbert
7,833 PointsI keep getting an error stating that I have not declared the method getFullName() when I have. Please help!
Hopefully self-explanatory when you see my code. Eager to understand where I'm going wrong.
struct Person {
let firstName: String
let lastName: String
func getFullName(firstName: String, lastName: String) -> String {
return "\(firstName) \(lastName)"
}
}
1 Answer
Moritz Lang
25,909 PointsHi Henry,
why do you want to pass firstName
and lastName
as parameters to the method? Getting past this challenge is as easy as following the rules in the question :)
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
Henry Gilbert
7,833 PointsHenry Gilbert
7,833 PointsI confused myself with regards to scope. Thinking that I had to pass the parameters in order to call upon them within the method.
Thank you so much for your help!