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 trialEli MBS
1,158 Pointsswift object oriented programming
Object-Oriented Programming seems quite difficult to me... I don't understand this challenge and would be glad if someone could help me a little bit with it :)
struct Person {
let firstName: String
let lastName: String
func getFullName(firstName: String, lastName: String) {
return "\(firstName) \(lastName)"
}
1 Answer
Anjali Pasupathy
28,883 PointsYou've nearly got the function right. You need to specify the return type, and you need to add in a closing curly bracket. You also shouldn't have any parameters passed into the function. You're writing the function inside the struct, so the function already knows that firstName and lastName exist.
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
I hope this helps!
samarth sharma
1,758 Pointssamarth sharma
1,758 Pointsthanks
Anjali Pasupathy
28,883 PointsAnjali Pasupathy
28,883 PointsYou're welcome! (: