https://kotlinlang.org logo
Title
y

yusuf3000

03/20/2018, 8:33 AM
Beginner kotlin developer here. In swift land, when I wanted to create constants I would declare an enum which contains static variables:
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

yusuf3000

03/20/2018, 9:11 AM
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

Andreas Sinz

03/20/2018, 9:26 AM
i've actually never done a multiplatform project, so you better ask that question in #multiplatform