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 trialKhadeeja Yasser
2,455 PointsI'm confused as to why my code is wrong
It is stating that the error is that my code doesn't return a string. But it does...and I know that because it worked in Xcode and returned both the first and last name with a space in between. I need to know what is wrong.
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
let firstName = "Khadeeja"
let lastName = "Yasser"
let fullThing = firstName + " " + lastName
return fullThing
}
}
let someThing = Person(firstName: "Khadeeja", lastName: "Yasser")
someThing.fullName()
1 Answer
Stuart Wright
41,120 PointsThe important thing to note here is that you should not be hardcoding values inside your method. You should delete these lines:
let firstName = "Khadeeja"
let lastName = "Yasser"
The whole point of the method is that you can pass in whatever values you like later. Let me know if you need any more help.