Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Fredrick Barrett
2,068 PointsWhy does initializing startDate "self.startdate = startDate" give an error saying assigning a property to itself?
In the video, there are no errors when Pasan writes this, but in my playground there is an error
2 Answers

Jhoan Arango
13,603 PointsFredrick,
At a first glance, I do not see the parameter in the initializers signature named "startDate". With that said, the error is showing because you are initializing "startDate" from it's own property.
To fix this, add the parameter "startDate" to the initializer. ( change the name from date to startDate )
init(name: String, address: String, startDate: Date, type: EmployeeType) {
self.name = name
self.address = address
self.startDate = startDate
self.type = type
}
OR if you want to use "date", you have to initialize it this way.
init(name: String, address: String, date: Date, type: EmployeeType) {
self.name = name
self.address = address
startDate = date // Note that "self" is no longer required
self.type = type
}
// Self is not required because there is no ambiguity
// between the parameter name and the property
Hope this helps.

Fredrick Barrett
2,068 PointsThank you, this helped so much

Fredrick Barrett
2,068 Pointsclass Employee { let name: String let address:String let startDate: Date let type : EmployeeType
init(name: String, address: String, date: Date, type: EmployeeType) {
self.name = name
self.address = address
self.startDate = startDate
self.type = type
}
}
Jhoan Arango
13,603 PointsJhoan Arango
13,603 PointsHello,
Would you be able to provide your code ?