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

Alice Muir
Alice Muir
1,479 Points

Hi there, I don't understand why this code won't pass the compiler?

struct Person {
    let firstName: String
    let lastName: String

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

let aPerson = Person(firstName: "Steve", lastName: "Hunter")
let fullName = aPerson.getFullName()
structs.swift
struct Person {
    let firstName: String
    let lastName: String

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

let aPerson = Person(firstName: "Steve", lastName: "Hunter")
let fullName = aPerson.getFullName()

Moderator edited: Markdown added so that code renders properly in the forums.

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Alice Muir! It looks like you're doing fantastic! However, as you've probably noticed, these challenges are very particular about certain things. In this case, it's having a problem with the method name and also with the final constant you declared.

It asks for the method to be named fullName, but you named it getFullName. On the second step, the challenge asks for the constant to be named myFullName but you named it fullName, which was supposed to be the name of the method :smiley:

Once I fix the naming of those two things, your code passes with flying colors! Hope this helps! :sparkles:

Alice Muir
Alice Muir
1,479 Points

Got it, thanks so much! :)