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 trialmahi
7,137 PointsI just can't figure this out!!!
I am not able to get it. i've been trying this from last one hour but am able to crack this.
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String{
return "\(firstName) \(lastName)"
}
}
2 Answers
William Li
Courses Plus Student 26,868 PointsAre you having trouble with part 2 of this challenge?
part 2 requires you to do 2 things, and it goes as follow.
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String{
return "\(firstName) \(lastName)"
}
}
// step 1
// use the struct to create an instance of Person and assign it to a constant named aPerson.
// Assign any values you want to the first and last name properties.
let aPerson = Person(firstName:"John", lastName:"Doe")
// step 2
// call the instance method and assign the full name to a constant named fullName.
let fullName = aPerson.getFullName()
Let me know if you have question about the code.
mahi
7,137 Pointsthanks a lot!!
Paul Brazell
14,371 Pointsstruct Person {
let firstName: String
let lastName: String
func getFullName() -> String{
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: "A", lastName: "Person")
let fullName = aPerson.getFullName()
mahi
7,137 PointsThanks a lot!!!
mahi
7,137 Pointsmahi
7,137 PointsThe step after this challenge which asks to create an instance method getFullName() in the struct Person, am not able to crack that.