<@UFC7B9QPM> I submitted a feature request for all...
# announcements
l
@thana I submitted a feature request for allowing to explicitly request use of
contentEquals
a while ago: https://youtrack.jetbrains.com/issue/KT-26499 You can add your vote.
e
I always wanted to ask what’s the use-case of storing arrays in data classes? Where does it come up?
b
I can't recall if `inline class`es can do this, but this kind of thing is useful in other languages when you want type-level validation:
data class NonEmptyList<T>(val values: List<T>)
then you throw in
init
if the list is empty. That's the use case that comes to mind for me anyway
p
@basher but you are storing
List
, not
Array
🙂
t
@elizarov in my case i need to satisfy a javascript interface which requires an array here and not a list
👍 1
e
Ah, I see. Inline classes would help here when they are really supported by JS backend.
b
@Pavlo Liapota fair point! Same idea though?
p
The issue is with arrays only.
equals()
of a
List
compares elements and
toString()
shows elements, but it does not like that for arrays.
Copy code
arrayOf(1) == arrayOf(1) // false
listOf(1) == listOf(1) // true
👍 1
l
@elizarov Use case is for primitive arrays and unsigned number arrays, where using
List
means performance hit due to autoboxing and you don't need variable size or read-only defense.
e
Thanks. That makes sense.