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

Trevor Justice
Trevor Justice
1,965 Points

struct Coding Challenge Help


I'm new to programming and trying to complete this coding challenge using structs and methods. I'm working in my Xcode Playground, and have tried every variation of things I could think of to put inside fullName, yet I always get an error by return which reads ¨Unexpected non-void return value in void function¨. If anyone could explain to me why the code isn't working, and suggest a way to fix it, I would greatly appreciate it.

Thank you! Trevor

struct Person {
    let firstName: String
    let lastName: String

    func fullName(first: String, last: String) {
      let name = first + last

      return name

1 Answer

You are attempting to return a string from a function that is expected to return Void(which means nothing). The function must be:

func fullName(first: String, last: String) -> String
Trevor Justice
Trevor Justice
1,965 Points

Thank you, I understand now!