We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 99f3546 commit 90f28a2Copy full SHA for 90f28a2
tp7/src/main/kotlin/fmt/kotlin/fundamentals/Cellar.kt
@@ -5,7 +5,18 @@ import jdk.internal.org.jline.utils.Colors.s
5
data class Cellar(
6
val bottles: List<Bottle>
7
) {
8
- fun describeAll(): String = TODO()
+ fun describeAll() = callOnEveryBottle(Bottle::describe)
9
10
- val years: String = TODO()
+ val years
11
+ get() = callOnEveryBottle {
12
+ it.year.toString()
13
+ }
14
+
15
+ private fun callOnEveryBottle(block: (Bottle) -> String): String {
16
+ var res = ""
17
+ for (bottle in bottles) {
18
+ res = res + "\n" + block(bottle)
19
20
+ return res
21
22
}
0 commit comments