Skip to content

Commit adeb06c

Browse files
replace StringBuilder with joinToString
1 parent dcce95a commit adeb06c

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,9 @@ fun NewsResourceAuthors(
157157
) {
158158
if (authors.isNotEmpty()) {
159159
// display all authors
160-
val authorName = StringBuilder()
161-
authors.forEachIndexed { index, author ->
162-
authorName
163-
.append(author.name)
164-
.append(if (index == authors.lastIndex) "" else ", ")
165-
}
166-
167-
val authorNameFormatted = "$authorName".uppercase(Locale.getDefault())
160+
val authorNameFormatted =
161+
authors.joinToString(separator = ", ") { author -> author.name }
162+
.uppercase(Locale.getDefault())
168163

169164
val authorImageUrl = authors[0].imageUrl
170165

0 commit comments

Comments
 (0)