dave08
04/22/2018, 2:34 PMinvoke operator to initialize an enum class? I tried as an extension function, but the Intellij doesn't seem to see the constructor...kingsley
04/22/2018, 2:38 PMdave08
04/22/2018, 2:40 PMenum A() { B, C }
operator fun A.invoke(s: String) = if (s == "something") A.B else A.Cdave08
04/22/2018, 2:41 PMA("something")kingsley
04/22/2018, 2:42 PMA("something"), you need either to use the companion object invoke, or a factory function:
fun A(s: String) = if (s == "something") A.B else A.Cdave08
04/22/2018, 2:45 PMstatic members, but forgot they're called on the actual instance... 🙈. Thanks for the explanation!