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

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! :)