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 trialMaxence Roy
8,753 PointsNot sure what to do from here
I'm not sure what to do after I assigned the Person() instance to the aPerson constant?
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
let fullName = firstName + " " + lastName
return fullName
}
}
let aPerson = Person(firstName: "John", lastName: "MacMiller")
2 Answers
Jordan Barr
21,335 PointsHey Max,
I was just stuck on this one too, i found the wording quite confusing but eventually got there.
Your first line of code is great and creates the instance of the Person struct. The next thing you need to do is use the 'fullName()' method on that new instance and assign to the new constant.
so my code would look like this:
let aPerson = Person(firstName: "John", lastName: "MacMiller")
let myFullName = aPerson.fullName()
remember we cant use the method directly on the name of the struct (being 'Person') which is why we need to call it on the constant 'aPerson'
hope this helps :)
cheers, Jordan
Maxence Roy
8,753 PointsThanks Jordan! I'm having trouble with object oriented programming but thanks for the tip, I succeeded at the test!
Jordan Barr
21,335 PointsNo problem! I'm also finding it challenging (well a good challenge!) anyway good luck!