Last active
October 8, 2016 03:12
-
-
Save wh1pch81n/2eea1d3033734d317b4f1bdfb740aa1d to your computer and use it in GitHub Desktop.
An example of stringifying an enum string state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum PageNames: String { | |
| case sc🖍search = "MySearch" | |
| var page_name: String { | |
| return String(describing: self).replacingOccurrences(of: "🖍", with: "/") | |
| } | |
| } | |
| PageNames.sc🖍search.rawValue // "MySearch" | |
| PageNames.sc🖍search.page_name // "sc/search" | |
| PageNames(rawValue: "MySearch")?.page_name // "sc/search" | |
| PageNames(rawValue: "blh")?.page_name // nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment