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

John Conner
John Conner
950 Points

struct.swift code challenge: Person { Hard time setting up this solution

This question pertains to the 1 of 2 part code challenge creating a struct Person { I am have issues setting it up to solve

struct Person { let firstName: String let lastName: String

structs.swift
struct Person {
    let firstName: String
    let lastName: String
func fullName()

var results = [Person]()
}
return results
}

1 Answer

Nick Frozz
Nick Frozz
31,289 Points

Hi John, Let's start it from the top:

1st of all you need to create a function named "fullName" that returns a String ( -> String ).

2nd, In the body of that function, you need to return a string by using string interpolation"(constant's name)" for both constants that "Person" struct contains.

And a little hint: In the body of that function, don't create an another one constant named "results", just use a "return" statement.

func fullName() ... {

return // and pass your solution here

}

GL with the solution, I hope my comment won't confuse you even more )