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

Ian Henderson
Ian Henderson
5,512 Points

Why is code challenge crashing? Is my code causing it?

First, the "full name code challenge" in object-oriented Swift 2.0 keeps crashing. I can't progress. Second, from the challenge instructions and given code, it seems like I am supposed to use struct Person as the input and output a Concatenated or Interpolated String. My code is below. Am I doing something wrong that is causing the crash?

struct Person { let firstName: String let lastName: String

func getFullName(fullName: [Person]) -> String{
    let name = "\(firstName) \(lastName)"
    return name
}

}

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

    func getFullName(fullName: [Person]) -> String{
        let name = "\(firstName) \(lastName)"
        return name
    }
}

let name1 = Person(firstName: "Ian", lastName: "Henderson")

3 Answers

Nicholas Richardson
Nicholas Richardson
4,867 Points

Hello,

I noticed on your function you are passing it full name when I believe that is what the intent of the function is to create. I completed the code challenge with the following code.

struct Person {
    let firstName: String
    let lastName: String

    func getFullName() -> String {

        let fullname = firstName + " " + lastName

        return fullname
    }
}

// Not needed to complete the challenge just used to make sure everything was working!
let aPerson = Person(firstName: "Nicholas", lastName: "Richardson")
let fullName = aPerson.getFullName()

Hope this helps!

same i keep getting error messages....."Oh no! There was a temporary issue running this code challenge. We've been notified and will investigate the problem.

If you continue experiencing problems, please contact support at help@teamtreehouse.com.

Restart Challenge Back to overview"

Code challenges are not working for me either, i think it's something wrong on the other end