Skip to content

Instantly share code, notes, and snippets.

@0xtmphey
Last active October 9, 2019 07:47
Show Gist options
  • Save 0xtmphey/c696f22d85c2e7efa2b1153b60418ec5 to your computer and use it in GitHub Desktop.
Save 0xtmphey/c696f22d85c2e7efa2b1153b60418ec5 to your computer and use it in GitHub Desktop.
enum class Environment(val id: String) {
DEVELOPMENT("development"),
PRODUCTION("production");
companion object {
fun create(env: String): Environment =
when (env) {
"development" -> DEVELOPMENT
"production" -> PRODUCTION
else -> throw Exception("Unsupported environment $env")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment