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 trialshane reichefeld
Courses Plus Student 2,232 Pointscan Someone explain what this is asking for and what it needs? and why?
Need clarification
struct Person {
let firstName: String
let lastName: String
}
1 Answer
Paul Brazell
14,371 PointsThe question is asking you to create a method as part of the Person struct. All this means is that you create a function inside the body of the struct.
This specific method is asking you to combine the first and last name fields to generate a full name. You would do this more than likely using string interpolation or you could use concatenation. you aren't passing anything extra into the function, so it wouldn't have any parameters. It would however be returning the string containing the full name.
In the return, all you do is combine the first and last name to generate the full name.
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}