最佳答案
I have an enum with some instances Foo
and Bar
. If I have a string "Foo"
, how can I instantiate a Foo
enum from that? In C# it would be Enum.Parse(...)
, is there an equivalent in Kotlin?
Currently, the best I have found is to create a factory that switches on all possible strings, but that is error prone and performs poorly for large enumerations.