我在这里看到了很多枚举方法的接口示例,但我正在寻找另一件事。
我想确保一些字符串枚举至少有三个键:
enum InterstitialEnum(val webName: string) {
Showed("interstitialShowed"),
Dismissed("interstitialDismissed"),
Failed("interstitialFailed"),
SomeInterstititalValue("intersititalSomeValue")
}
enum VideoEnum(val webName: string) {
Showed("videoShowed"),
Dismissed("videoDismissed"),
Failed("videoFailed"),
VideoSomethingHere("videoSomethingHere")
}
我的最终目标是将该接口用作函数参数,以便我可以访问 functionParameter.Showed.webName
等。
我试图创建一个接口,但我找不到定义函数的方法Showed
,Dismissed
或者Failed
只是函数。
这不起作用
interface BaseEnum {
val FailedToShow: String;
}
编辑:
重要的是,这不是如何在 Kotlin 中扩展枚举的副本?因为我不想要相同的key
/value
对,我想要相同key
的不同的value
.