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 trial

iOS Object-Oriented Swift Complex Data Structures Adding Instance Methods

Again, totally lost here. Any help would be appreciated.

Again, I'm at this point of having no idea what to type BUT if someone placed the answered question in front of me I could read it fine AND I would probably feel stupid because it would seem so obvious. It's like, I can read the code but I cannot write it to save my life. Also, as I've mentioned in a previous question post I feel there is a disconnect between the videos leading up to the tasks and then the tasks themselves. It's like, some good task might be just getting you to repeat out some of the previous material so you can get used to typing the data etc, and this is coming from someone who is copying every single thing in the videos religiously.

Any case, if someone could help point me in the right direction for getting the logic on this that would be awesome.

structs.swift
struct Person {
    let firstName: String
    let lastName: String

    func fullName(firstName, lastName) {
      return.fullName
    }
}

Ignore that code I've written as well. I didn't realize I had that in there when I attached the code to the post.

Dave Faliskie
Dave Faliskie
17,793 Points

because fullName is a method of Person, it already has access to firstName and lastName try something like:

func fullName() -> String {
    return "\(firstName) \(lastName)"
}

1 Answer

Kevin D
Kevin D
8,646 Points

So it looks like it's because you're not returning the first name, and last name in your fullName(firstName, lastName) function.

Hopefully that pushes you in the right direction :)