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 trialBalazs Meyrhuber
986 PointsCode could not be compiled but in the preview there is no text
What did I do wrong?
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
return("\(firstName)" + " " + "\(lastName)")
}
}
let aPerson = Person(firstName: "Balazs", lastName: "Meyrhuber")
let myFullName = Person.fullName(aPerson)
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Balazs,
You are on the right track, but a bit off on the last line of code.
aPerson
is already of type Person
, so to call the method on it, it is done directly with dot notation. The fullName
method doesn't take any parameters, so none can be passed in, as you have done. Basically, you have all the elements needed, just a bit mixed up. Just remember, you already made the Person instance, you are now just calling the method directly on that instance.
let myFullName = aPerson.fullName()
Hope that helps to make sense. :)
Keep Coding!
Balazs Meyrhuber
986 PointsThank you, it worked. :D