Is there something like associated types in Swift ...
# getting-started
n
Is there something like associated types in Swift in Kotlin? The problem I’m facing is that I need create instances of enums that satisfy a certain interface. Those enums have an associated value, e.g.
Monday(1)
,
Tuesday(2)
, etc. So from
1
I need to get a
Monday
instance. I understand that a factory can be declared as a
companion object
. But then I need to set a requirement for a certain companion object in the
interface
that that enum implements. Otherwise I cannot come up with a generic solution. Any ideas?