mzgreen
08/28/2016, 12:25 PM// Kotlin
enum class A {
; //this is important - without it compiler won’t like it
fun a() {}
}
//Java
enum A {
; //this is important - without it compiler won’t like it
public void a() {}
}
but without constants there is no way to call this method. In Java we can make it static
and then it can be called. In kotlin it has to be wrapped in a companion object
.
My question is - why such a thing even exists? Why compiler allows it to compile? I can’t see any use case for this. Any ideas?