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 trialGokul Nishanth S
1,349 PointsMake sure your function does not take any parameters and returns a String
struct Person
{
let firstName: String
let lastName: String
func fullName() -> [String] // remove square brackets
{
return ["\(firstName) \(lastName)"] // remove square brackets
}
}
let name = Person(firstName: "Gokul", lastName: "Nishanth")
name.fullname()
1 Answer
Steve Hunter
57,712 PointsHi there,
I don't think you need the square brackets around the returned data type or the returned value itself. The rest looks OK.
Try:
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
return "\(firstName) \(lastName)"
}
}
I hope that helps,
Steve.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsI added some comments in your code to illustrate my point.
Steve.
Gokul Nishanth S
1,349 PointsGokul Nishanth S
1,349 PointsThank You.
But my code works fine in Xcode Playground. What maybe the problem here.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem!