hey guys — is there any way I can keep a data clas...
# getting-started
m
hey guys — is there any way I can keep a data class property declared as
Long
exposed as a boxed
java.lang.Long
, as opposed to a
long
primitive? Other than making it nullable, that is.
This is a class that used to be coded in Java and was converted to Kotlin; I do want to take advantage of null-safety from Kotlin code, but I’d like to keep the same types used in the old Java class.
s
use
java.lang.Long
explicitly?
you can add a typealias for it (when importing or whatever)
m
that makes Kotlin code very awkward though; every assignment will require a typecast
s
I'm not sure why that isn't getting implicitly autoboxed