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

not to sure what i am writing wrong

can someone explain where I am wrong in this situation and explain to me the proper way to write this down

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

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


    }

}

1 Answer

Michael Hulet
Michael Hulet
47,913 Points

Your code looks really good! The only real problem I see is that the return type is different than what the challenge is expecting. The challenge is expecting a String, but you're returning a (String), which is subtley different. In Swift, when you're talking about data types, it's important whether or not you're wrapping your type in parentheses. If it's wrapped in parentheses, it makes it a tuple with a single value of your type. A tuple is basically just an immutable Array. Thus, your code is returning a tuple with a single value of type String, but you want it to return just a String. If you remove the parentheses there and put a space between firstName and lastName in the String you return, I believe you'll pass the challenge. Great job!

Ahh i see, I didn't catch that I had put the string around parenthesis. Thank you.

I am having one additional problem. It is telling me that I need to ensure that there is a space between the first and last name and cannot figure out how to do so, could you lend me some assistance?