Skip to content

Захарченко Марк Дз#7

Open
Shadowik2306 wants to merge 1 commit intoMadBrains:masterfrom
Shadowik2306:master
Open

Захарченко Марк Дз#7
Shadowik2306 wants to merge 1 commit intoMadBrains:masterfrom
Shadowik2306:master

Conversation

@Shadowik2306
Copy link
Copy Markdown

No description provided.

// Вернуть словарь в котором названия городов являются ключами, а значениями - сет клиентов, проживающих в этом городе
fun Shop.groupCustomersByCity(): Map<String, Set<Customer>> = mapOf()

@OptIn(ExperimentalStdlibApi::class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эт тебе зачем?

fun Shop.groupCustomersByCity(): Map<String, Set<Customer>> = mapOf()

@OptIn(ExperimentalStdlibApi::class)
fun Shop.groupCustomersByCity(): Map<String, Set<Customer>> = buildMap <String, Set<Customer>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно проще customers.groupBy { it.city.title }.mapValues { it.value.toSet() }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants