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 Complex Data Structures Adding Instance Methods

Maxence Roy
Maxence Roy
8,753 Points

Help please

Hi,

I think there's something deeper that I don't understand but here's my code.

Please help, thanks.

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

    func fullName(Person: String) ->  String {
        let fullName: String = firstName + " " + lastName
        return fullName
    }
}

1 Answer

andren
andren
28,558 Points

The issue is the Person parameter you have declared for the method. That parameter does not belong there, as the method does not require anything to be passed into it. And in fact you don't end up using it that parameter in the code you wrote either.

If you simply remove it like this:

struct Person {
    let firstName: String
    let lastName: String

    func fullName() ->  String {
        let fullName: String = firstName + " " + lastName
        return fullName
    }
}

Then your code will pass task 1.