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 trialAry de Oliveira
28,298 PointsSwift 2.0 Object Oriented Challenge Task 2 of 2.
Challenge Task 2 of 2 Let's use the struct to create an instance of Person and assign it to a constant named aPerson. Assign any values you want to the first and last name properties. Once you have an instance, call the instance method and assign the full name to a constant named fullName. I miss same thing here.... we try
struct Person {
let firstName: String
let lastName: String
func getFullName() -> String {
return "\(firstName) \(lastName)"
}
}
init (firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
}
Ary de Oliveira
28,298 Pointswe work hard here to, meet our customer required, thanks for reading our code Swift 2.0 Object Oriented Challenge Task 2 of 2.
Challenge Task 2 of 2 Let's use the struct to create an instance of Person and assign it to a constant named aPerson. Assign any values you want to the first and last name properties. Once you have an instance, call the instance method and assign the full name to a constant named fullName. I miss same thing here.... we try structs.swift struct Person { let firstName: String let lastName: String func getFullName() -> String { return "(firstName) (lastName)" } } init (firstName: String, lastName: String) { self.firstName = firstName self.lastName = lastName }
Kim Sorgalla
2,174 PointsSorry, can you please specify what your problem is?
2 Answers
Gonzalo Nunez
Courses Plus Student 5,064 Pointslet aPerson = Person(firstName: "A", secondName: "B") let fullName = aPerson.getFullName
Donan Jackson
iOS Development Techdegree Student 1,690 PointsHey Gonzalo!. It's Donan from Pixar.
Andrew Lee
1,834 Points// First you must create an instance of a Person. You do this by gving the instance a name, in this case aPerson.
// Then you must use the struct, Person, to define the characteristics of the struct. The characteristics in this case being firstName and lastName:
let aPerson = Person(firstName: "Albert", lastName: "Einstein")
//Finally you must call the instance method and assign the value to a constant, in this case the constant is to be called fullName.
// You assign the value as always by giving it a name (fullName) followed by the = sign. Then you call the method by using .getFullName (you call all methods by using the full stop followed by the method name, e.g you would add to something using .append)
let fullName = aPerson.getFullName()
elk6
22,916 Pointselk6
22,916 PointsHi Ary,
I've noticed that you ask all your questions twice. Might not be on purpose but would you try to create a question only once? Thanks!