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 trialBen Forrester
Courses Plus Student 5,357 PointsgetfullName instancd method issue
struct Person { let firstName: String let lastName: String
func getFullName (fullName: Person) -> String/* <- This is the Instance method but the compiler on the website says Bummer! Make sure you're adding an instance method named getFulleName(). This runs fine in the playground. Not sure what is wrong*/
{
return firstName + lastName
}
} let fullName = Person(firstName: "Ben", lastName: " Forrester") fullName.getFullName(fullName)
struct Person {
let firstName: String
let lastName: String
func getFullName (fullName: Person) -> String
{
return firstName + lastName
}
}
let fullName = Person(firstName: "Ben", lastName: " Forrester")
fullName.getFullName(fullName)
1 Answer
Tobias Helmrich
31,603 PointsHey Ben,
you don't have to give the getFullName
method any parameters as the method already has access to the stored properties of the struct. The second problem I can see is that you forgot to add a space between the first name and the last name.
This is a working example for the first task of the challenge:
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return firstName + " " + lastName
}
}
I hope that helps! :)