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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Adam Peruta](https://secure.gravatar.com/avatar/2692da30bbde363970b8d25fa0b6c6e7?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Adam Peruta
4,919 PointsHow to print out the status here?
In this example, how would you print out the status (rather than it just saying Enum Value)?
![Kristofer Doman](https://uploads.teamtreehouse.com/production/profile-photos/2659192/micro_15774802_10157964860960134_5006416656721059467_o.jpg)
Kristofer Doman
18,307 PointsI don't believe there's a way to do this yet. There's a couple work arounds for this. One of which would be adding a String Description as a raw value to each case. Another way would be to create a func with a switch case I believe which would return a value dependant on self.
2 Answers
![Dennis Parussini](https://uploads.teamtreehouse.com/production/profile-photos/50476/micro_ikke_nieuw.jpg)
Dennis Parussini
Treehouse Project ReviewerYou can. Just add rawValues to the enum
enum Status: String {
case Doing = "Doing", Pending = "Pending", Completing = "Completing"
init() {
self.init()
}
}
and then:
var task = Task(description: "Learn Swift", status: .Pending)
println("\(task.status.rawValue)")
![Joshua Rystedt](https://uploads.teamtreehouse.com/production/profile-photos/3611092/micro_fullsizeoutput_1f3f.jpg)
Joshua Rystedt
4,086 PointsI actually worked on this when completing the challenge. My solution was to use a method within the struct.
func printStatus() {
let status = self.status
if status == Task.Status.Completed {
println("This task has been completed")
} else if status == Task.Status.Doing {
println("This task is being done")
} else if status == Task.Status.Pending {
println("This task is pending")
} else {
println("Error! I don't know what the status is.")
}
}
Adam Peruta
4,919 PointsAdam Peruta
4,919 PointsI think I figured it out:
You can just add raw values to the enum and then use:
task.status.rawValue
Am I right?