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!

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

Objected-Oriented Swift 2.0 - Challenge Task 2 of 2

Hello, I don't understand why my code doesn't work :

struct Person {
    let firstName: String
    let lastName: String

    func getFullName() -> (String) {
        var result: String = ("\(firstName) \(lastName)")
        return result

let aPerson = Person(firstName: "Emilie", lastName: "Sidoli")
let fullName = aPerson.getFullName()

Thanks for your help !

2 Answers

Martin Wildfeuer
Martin Wildfeuer
Courses Plus Student 11,071 Points

Ok, I know this one is extra confusing. Everything you did works perfectly and Xcode won't complain either. However, code check is a bit picky and does not accept parenthesis around the return type. Only at the second task, though, which adds up to the confusion :)

// Remove parenthesis from return type
func getFullName() -> String {
    var result: String = ("\(firstName) \(lastName)")
    return result

As a rule of thumb I would say don't add parenthesis where not necessary, just as it is the case with -> String

Hope that helps :)

Thank you very much Martin !! You're right, it was tricky. But now I can pursue :)

Have a good day !