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

I don't understand

This is my code, I worked on it for a while and couldn't get the correct answer so I googled the instructions and found another person with the same question, and several answers. However even using the solutions that seemed to work for the other person I cannot get the site to let me pass, is there some error or typo that I'm missing?

Thanks.

structs.swift
struct Person {
     let firstName: String
    let lastName: String
    func getFullName() -> String {
    return "\(firstName) \(lastName)"
    }
}
let aPerson = Person(fistName: "james", lastName: "may")
let fullName = aPerson.getFullName()

1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Luke Anderson,

There's just a small typo. You're missing the "r" for your first argument of the Person initialization.

struct Person {
     let firstName: String
     let lastName: String

    func getFullName() -> String {
       return "\(firstName) \(lastName)"
    }
}
// typo was here in firstName
let aPerson = Person(firstName: "james", lastName: "may")
let fullName = aPerson.getFullName()

Good Luck