Beginner kotlin developer here. In swift land, whe...
# announcements
y
Beginner kotlin developer here. In swift land, when I wanted to create constants I would declare an enum which contains static variables:
Copy code
enum Constants {
    static let randomNumber: Int = 42
    static let randomString = "42"
    static let randomNonPrimitiveType = CustomClass(number: 42)
}
Then use it like so:
let constantsUse = Constants.randomNonPrimitiveType
What’s the best way to do this in Kotlin? Especially if the constant is a non primitive type.
y
thankyou, just what i needed!
Actually @Andreas Sinz I still have an issue. I’m writing a kotlin multiplatform project so I don’t have access to the
@JVMField
annotation for non primitive types. What’s my next best option?
a
i've actually never done a multiplatform project, so you better ask that question in #C3PQML5NU