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

Martel Storm
Martel Storm
4,157 Points

Object-Oriented Swift 3 Adding Instance Methods Quiz I suck at Code

Can someone explain to me why it's not letting me pass?

Also any extra Code wisdom as I continue on this journey would be greatly appreciated.

Thanks in advance!

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

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

let myName = Person(firstName:"Mickey", lastName:"Mouse")
let results = myName.fullName()

1 Answer

David Papandrew
David Papandrew
8,386 Points

Hi Martel,

All you need to do to pass this challenge is REMOVE the comma in the fullName return statement string.

    return "\(firstName) \(lastName)" // This line, take out the comma in your code above

As for sucking at code, don't sweat it. Programming is frustrating for most of us. I've lost count of how many times I've been stymied by the tiniest of typos. You'll improve. It just takes time and lots of practice. You'll start seeing the patterns and the little things to look for as you gain experience (just don't quit early, there will be payoff down the road). The problems and hiccups don't go away, but the difference is that, with experience, you'll immediately know what types of solutions to consider when troubleshooting your code.

Good luck.

Martel Storm
Martel Storm
4,157 Points

"The problems and hiccups don't go away, but the difference is that, with experience, you'll immediately know what types of solutions to consider when troubleshooting your code" - Love that part. Thanks David!