How to convert enum case to the string type?

Sometime, you might need the enum’s case name as a string, but the rawValue.

In that case, you need the class

“String(describing:)”

Use this.

String(describing: YOURENUM.YOURCASE)
and then ‘YOURCASE’ will be printed.

--

--

--

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Typescript — How to solve the problem with unresolved path aliases in transpiled .js files

Buffer.compare() in nodejs

Tutorial Node.js: REST API (Calculator)

cloud translation api has not been used in project before or it is disabled

A Programmer Wronged Some Young Founders And No One is Talking About It

What is React Used For?

10 Tips and Best Practices to Improve JavaScript Performance of websites and applications

Bindings in Angular

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fredric Cliver

Fredric Cliver

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧

More from Medium

CS373 Spring 2022: Week 9 Ting-Yin Chang Chien

Application of Data Hub based on web 3.0 in DigiHealth platform of project IVIRSE

CS373 Spring 22 Blog #9: Daniel Dominguez Arroyo

CS371p Spring 2022: Christopher Carrasco — Week 14