Von der Kotlin Koan Frage ( https://github.com/Kotlin/kotlin-koans/blob/master/src/ii_collections/n16FlatMap.kt) habe ich diesen Koan-Code. Wie lese ich das? Es sieht aus wie eine Variable mit val
, aber es ist eine Funktion mit ()
und {}
.val ... get() {...} in Kotlin
val Customer.orderedProducts: Set<Product> get() {
// Return all products this customer has ordered
todoCollectionTask()
}
sieht aus wie ein impliziter Getter – njzk2
bei https://kotlinlang.org/docs/reference/properties.html Dokumentierte. –