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

code not working

Given the struct below in the editor, we want to add a method that returns the person’s full name. Declare a method named getFullName() that returns a string containing the person’s full name. Note: Make sure to allow for a space between the first and last name

struct Person {
    let firstName: String
    let lastName: String

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

}

2 Answers

The closing bracket of the getFullName method is missing.

struct Person {
    let firstName: String
    let lastName: String

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

}

i'm sorry, what do you mean?

struct Person {
    let firstName: String
    let lastName: String

    func getFullName() -> String {
       return "\(firstName) \(lastName)"
    }  <=============================== Your code is missing this brace ====================

}

Thanks Caleb Kleveter, I should have made it a bit more obvious :)

i read your code thinking it was my original code so i got confused sorry, my bad. i thought you quoted my original code so i thought the brackets where originally there ( still getting the hang of things on this ) thanks for your help both of you :)

No worries william fashanu , it's easy to miss the little things. However, I'd strongly recommend to not only use the code check here, but Xcode Playgrounds to test your code. That error would have been highlighted right away, not to mention that code completion would have added that bracket automatically. It makes our life so much easier ;)