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 trialJuras Rabačauskas
7,425 PointsInstance Methods Challenge
Hello, can anyone help me out with this challenge, thank you
struct Person {
let firstName: String
let lastName: String
func getFullName() -> (String) {
return "\(firstName) \(lastName)"
}
}
let aPerson = Person(firstName: Juras, lastName: Rabacauskas)
let fullName = aPerson.getFullName()
2 Answers
Jennifer Nordell
Treehouse TeacherYou're doing great! The problem is in this line:
let aPerson = Person(firstName: Juras, lastName: Rabacauskas)
You simply forgot to put the names Juras in Rabacauskas in quotes. So it thinks those are variable names. And since it can't find any variables named that, it doesn't know what to do so you get a compiler error. Try this line:
let aPerson = Person(firstName: "Juras", lastName: "Rabacauskas")
You should be able to move to the next step after this small change. Good luck!
Juras Rabačauskas
7,425 PointsThanks!! Now thats a confidence boost! :D
Juras Rabačauskas
7,425 PointsIt didn't workout - I got an error "The value being assigned to fullName must be the result of calling the instance method getFullName()". Any more tips? Thank you very much.
Juras Rabačauskas
7,425 PointsThank you, I dont know why for me it's not working - I tried it and got "The value being assigned to fullName must be the result of calling the instance method getFullName()" error.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHere was the code I used to pass step 2. Take a look: