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

Get Full Name challenge

My code works in the playground. It's kind of verbose, but why doesn't it work in the challenge editor?

Promise to get some sleep and stop bugging you guys with my beginner questions after this..!

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

    func getFullName(firstName: String, lastName: String) -> String {
        let fullName = ("\(firstName) \(lastName)")
        return fullName
    }
}
let myself = Person(firstName: "Me", lastName: "Myself")
myself.fullName("Me", lastName: "Myself")

1 Answer

Nancy, your function doesn't need any parameters. The struct has firstName and lastName properties. The function is just supposed to use them to return a String, not to use some new firstName and lastName passed in from outside:

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