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

Need help with code challenge

I just can't seem to figure this one out, have tried everything;

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

    func getFullName(firstName name: String, name1: String) -> Person {


        let fullName = Person(firstName: name, lastName: name1)

        return fullName

    }
}

1 Answer

Hey Zeenia,

The main issue here is the code challenge just wants the getFullName() function, without specified parameters like you provide. Simply using the stored properties in the function while within the struct works. In addition, you're only returning a string of the person's full name, not a type of Person.

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