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

Not sure what Im missing here

Im not sure why I keep getting this challenge wrong! No matter what value I put in for 'firstName' or 'lastName' I always get "make sure you are returning the correct string. . ."

Could anyone explain to me what Im missing and what it does so I can understand its importance? Thanks!

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

    func getFullName() -> String  {
        let fullName = (firstName  + lastName)

        return fullName
    }
}

1 Answer

I believe the challenge wants you to put a space in between the names. The fastest way to do this IMO is through String interpolation, like this:

struct Person {
    let firstName: String
    let lastName: String

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

See, I tried that but I did it like this:

struct Person {
       let firstName: String
       let lastName: String

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

Is there something wrong with that?

Ill give your response a shot! Thank you!

The only thing I see wrong in your version is that you forgot the "t" in "lastName" in your getFullName function