Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,781 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 Dang
Kevin Dang
8,621 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 :)