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 trialheather wolfram
1,594 PointsI need a little help with this one
I think I have the majority of this figured out although anytime I try to recheck my work to move on it says it is wrong and that I need to make sure and name a constant myFullName and call the method in the struct or something like that and I am so confused!!! I know the last line of code is wrong, that was just a another failed attempt at wracking my brain for the answer. Please help!!! please please!!
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: "Heather", lastName: "Wolfram")
let fullName = aPerson.getFullName()
let myFullName = fullName
1 Answer
Nichlas Kondrup
17,748 PointsYou are very close. You just have to change the method name to "fullName()" and the "fullName" constant should be called "myFullName". Then delete the last line of code
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: "", lastName: "")
let myFullName = aPerson.fullName()