Here is a beginners question. In java one sometime...
# getting-started
h
Here is a beginners question. In java one sometimes uses
interface
to hold data-values
Copy code
public interface SymbolNames {
  String BeginPackage = "BeginPackage";
  String EndPackage = "EndPackage";
  String End = "End";
}
What is the equivalent in Kotlin? When I convert the above to Kotlin it gives me an interface with a companion object. Is this the way to go?
k
Either that or top-level values, yes. Or maybe this can actually be an enum?
h
Thanks! And top-level values mean basically just putting them inside the file like
Copy code
const val BeginPackage = "BeginPackage"
const val EndPackage = "EndPackage"
const val End = "End"
An enum doesn't really fits as it's really only a collection of similar things but not enumerable.
k
Yup that's what I meant.
A singleton might work too actually:
Copy code
object SymbolNames {
    ...
}
h
@karelpeeters Yes, a singelton is what I used in the end. Thanks again.