8000 io-to-data.6 : create resultLines · java-to-kotlin/code@0a5b391 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a5b391

Browse files
Duncan McGregordmcg
authored andcommitted
io-to-data.6 : create resultLines
1 parent ef3665e commit 0a5b391

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/travelator/marketing/HighValueCustomersReport.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ fun generate(writer: Writer, lines: List<String>) {
88
val valuableCustomers = lines
99
.toValuableCustomers()
1010
.sortedBy(CustomerData::score)
11-
writer.appendLine("ID\tName\tSpend")
12-
for (customerData in valuableCustomers) {
13-
writer.appendLine(customerData.outputLine)
14-
}
15-
writer.append(valuableCustomers.summarised())
11+
val resultLines = listOf("ID\tName\tSpend") +
12+
valuableCustomers.map(CustomerData::outputLine) +
13+
valuableCustomers.summarised()
14+
writer.append(resultLines.joinToString("\n"))
1615
}
1716

1817
private fun List<String>.toValuableCustomers() = withoutHeader()

0 commit comments

Comments
 (0)
0