I am trying to understand concept of inline classes - they are a simple object wrapper of single property that is being inlined during runtime. That means, that the actual initialization of the class is not happening at runtime
I was trying to write simple test which directly will show my above explanation during JUnit test as below:
companion object {
private const val NAME = "JACK"
}
inline class NameInlineClass(val value: String)
@Test
fun unwrapping() {
val nameInlineClass = NameInlineClass(NAME)
val name = nameInlineClass
assertEquals(name, NAME)
}
This test fails unfortunately which leads me to the question why during assertEquals()
the actual unwrapped String value is not being compared, but the actual inline class (which should be unwrapped during runtime)?