Will Kotlin get structs like Java? Currently a `va...
# language-proposals
m
Will Kotlin get structs like Java? Currently a
value class
gets optimised to use the same representation as the wrapped type, but what will happen when the class kind starts allowing more than one field? Will
value
types with one field be special cased?
a
the story is still in development (you can look at the discussion in the KEEP repo), but in the JVM value classes will become its own thing, and be optimized, once their "Project Valhalla" lands
m
@Alejandro Serrano.Mena Are you saying that it’s undecided?
Copy code
value class MyMono(val a: Int)
value class MyPair(
    val a: Int,
    val b: String,
)
I’m wondering if
MyMono
will be special cased to have the same representation as a bare
Int
and
MyPair
will be inlined such that instantiating it in a function would have the same representation as normal local
val a: Int
and
val b: String
declarations.