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

Ádám Csányi
PLUS
Ádám Csányi
Courses Plus Student 2,833 Points

Question: Let's use the struct to create an instance of Person and assign it to a constant named aPerson. Assign a

Hey everyone! I really need some help, cannot figure out why this is not working... Question: Challenge Task 2 of 2, thanks in advance for the suggestions.

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

    func fullName() -> String {
      return "\(firstName) \(lastName)"
    }
}
let aPerson = Person(firstName: "Adam", lastName: "Doe")
let fullName = aPerson.fullName()

1 Answer

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

Hi there! Your code is just fine and does what it's expected to do. But if you've come this far, then you know challenges can be super picky. This challenge requires that the last constant you assign be named myFullName, but you've named yours fullName.

let myFullName = aPerson.fullName()

Happy coding! :sparkles: