not data property?
2. what is data property? I can not find difinition in Properties
h
hfhbd
03/24/2024, 8:33 AM
I find the name "data property" confusing too, it’s not used anywhere else, but it stands for the properties defined in the (primary) constructor of a data class:
Copy code
data class Foo(val b: Int) {
val s: String = ""
}
b
is a "data property", while s is a normal property.
a
anlex N
03/24/2024, 8:43 AM
so crazy and confused. can we invite JetBrain team to answer this question?
c
CLOVIS
03/24/2024, 11:13 AM
There's nothing more to say, what Philip said is correct. A data property is just a property that's in the primary constructor of a data class.
It seems to be true that the term "data properties" is not defined properly before use on that page. However, it is defined formally in the Kotlin Language Specification:
A data class is a special kind of class, which represents a product type constructed from a number of data properties, [...], described in its primary constructor.
It may be worth asking someone from JetBrains if they would make the tutorial page on data classes clearer with respect to this definition.
g
gildor
03/26/2024, 7:19 AM
There is a literally "Edit page" button on top of the page to send PR