Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!