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

Aramik YOUSEFZADEH
PLUS
Aramik YOUSEFZADEH
Courses Plus Student 895 Points

I Get code error

I get an error saying : add fullName() method in the structure definition .

structs.swift
struct Person {
    let firstName: String
    let lastName: String
    func fullName (firstN : String , lastN : String) {          
       var result : String = (firstN + " " + lastN)
       return result 
        }
}

2 Answers

Perhaps it is because you have a space between your method name declaration and the opening parenthesis.

Hello, You did almost everything well, expect one thing. You forgot to define a return type to your function, and at defaulet it is Void. You have to do just one thing, add a String return type to your dictionary with the -> operator. It would look like that: func fullName (firstN : String , lastN : String) -> String { }

Keep it up :) Istvan