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 trialFarid Rasoolzadeh Baghmisheh
Courses Plus Student 1,650 PointsI did not initialise the enum, but made an init method in the struct where I initialise the status to .Pending. is OK?
Like this:
enum Status {
case Doing, Pending, Completed
}
struct Task {
var description: String
var status: Status
init(desc: String) {
self.description = desc
self.status = Status.Pending
}
}
1 Answer
Jhoan Arango
14,575 PointsHello Farid: Not sure what you are trying to do but yes, that can work.. BUT the only thing is that when you create an instance and then you access the properties of that instance you have to use .hashValue
enum Status {
case Doing, Pending, Completed
}
struct Task {
var description: String
var status: Status
init(desc: String) {
self.description = desc
self.status = Status.Pending
}
}
var runningTask = Task(desc: "Working on my homework")
runningTask.description
runningTask.status.hashValue