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 trialEmilio Robres
2,728 PointsHi, Why my code isn’t correct ? Please give me a hint. Best, Emilio
Hi,
Why my code isn’t correct ? Please give me a hint.
Best,
Emilio
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
let fullName = Person(firstName: "Emilio", lastName: "Robres")
fullName.getFullName()
In the Xcode works perfectly.
1 Answer
Steve Hunter
57,712 PointsHi there,
The tests behind the challenge are expecting certain things to be true. Your instance of Person
is expected to be called aPerson
. The method is called fullName
and the last task is expecting a constant called myFullName
to hold the full name of the Person
object after a call to the method you created in the first task.
If you don't create the correct names, the tests may fail even if your code 'works' in Xcode. But if the challenge wants an instance to be called aPerson
and you call it fullName
there's a risk that the challenge will fail as the output isn't what was required to pass the tests. Indeed the failure message says, Bummer! Make sure the value you're assigning to aPerson is an instance of Person
I hope that makes sense.
Steve.
Chanda Lupambo
Courses Plus Student 27,336 PointsChanda Lupambo
Courses Plus Student 27,336 Pointsyou have to assign fullName to a constant, read over the instructions if needed