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

Michael Bau
Michael Bau
3,394 Points

Help with fullName code challenge

Hi Community,

I know I am getting this all wrong, but, after having gone through the videos twice and making numerous attempts at solving this, I am still completely stuck with this challenge.

I would appreciate if someone, from the attached bit of code, could help me with hints towards the correct solution.

Thanks in advance and best regards, Michael

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

    func fullName(firstName: String, lastName: String) -> [Person] {
    var names = [Person]()
    }
    return names
 }

let names = Person(firstName: "John", lastName: "Petersen")

3 Answers

Jeff McDivitt
Jeff McDivitt
23,970 Points

Hi Michael -

  1. The task does not ask for arguments with your method; therefore, you can remove them.
  2. The task asks you to return a String you have it returning Person
  3. You need to return the first as last name combined
  4. On your instance check the constant name the task asks for
  5. You skipped the last part of the challenge
  6. Keep going as these concepts will be second nature to you with continued practice
struct Person {
    let firstName: String
    let lastName: String

    func fullName() -> String {

    return "\(firstName) \(lastName)"


    }
}

let aPerson = Person(firstName: "Jeff", lastName: "McDivitt")
let myFullName = aPerson.fullName()
Michael Bau
Michael Bau
3,394 Points

Hi Jeff,

Thanks for your help! It worked!

I must say, I am getting a bit frustrated with some of these challenges. They tend to vary so much from the examples from the videos leading up to the challenges, that these examples become more or less useless.

I am amazed that not many more get stuck and need to ask questions in order to proceed. Am I really the only one who doesn't get it?!

(Pardon me for ranting, I just needed to get it off my chest!)

Once again, thanks for your help, mate!

Best regards, Michael

Brendan Mauri
Brendan Mauri
932 Points

No you arent, i feel the same way. They teach you one thing. Then leave you on your own to do something that is either different, or way more complex then what they taught. Dont worry im in the same boat as you.

Michael Bau
Michael Bau
3,394 Points

Hi Brendan,

Thanks a lot for your response! It is actually a bit comforting to know that I am not the only one facing these issues.

I do find that there is a quite a bit of mismatch between was is being taught and what you are expected to do in the following challenges. I have also taken some html and css courses here, but hardly ever encountered the same issues with those. There, you always had a clear line from what was being demonstrated in the videos and the challenges you afterwards had to solve.

In this course I have reached a point, where I have to stop and ask the community at almost every single challenge, which makes progress very slow.

Had it not been for the fact that the community always responds quite fast and delivers answers of a very high quality, I am not sure I would have continued to this point.

All the best to you, I hope you manage to get past these obstacles!

Best regards, Michael