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 2.0 Complex Data Structures Adding Instance Methods

Ben Masel
Ben Masel
2,004 Points

Hello! I need to be steered on the right path because i don't really understand what to do, can anyone help?

Hi! I'm only 11 and I'm having trouble with this particular code challenge. I can't understand what I'm supposed to do and i haven't quite got structures down. Can u help?

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

    func getFullName() -> String {
      let Name = "\(firstName) \(lastName)"
      return Name
    }
}

let fullName = 

1 Answer

struct Person {
    let firstName: String
    let lastName: String


    func getFullName() -> String {

    return "\(firstName) \(lastName)"


    }
}

let aPerson = Person(firstName: "Benjamin", lastName: "Masel")
let fullName = aPerson.getFullName()

Try this :)

Also if I was you I wouldn't rush and move on, start from scratch re watch the videos re do the code challenges. Focus on understanding what is being said and try to write your own code. Ive completed this challenge like a month ago and I am still revisiting it as I don't think I understand it fully and I still forget certain things.

Each time you re watch the videos you will learn something new that you missed last time, and it solidifies your understanding.

Alia

Ben Masel
Ben Masel
2,004 Points

Sorry! I kept trying and I didn't understand the compiler when it said i made a mistake. So i kept starting from scratch.