Collections Introduction (Playground)
Description
This part was inspired by GS Collections Kata.
このパートは GS Collections Kata にインスパイアされています。
Default collections in Kotlin are Java collections, but there are lots of useful extension functions for them. For example, operations that transform a collection to another one, starting with 'to': toSet or toList.
KotlinのデフォルトのコレクションはJavaのコレクションですが、例えば 'to' で始まる toSet や toList といった、コレクションを別のコレクションに変換する、便利な拡張関数が多く備わっています。
Implement an extension function
Shop.getSetOfCustomers(). The classShopand all related classes can be found atShop.kt.
拡張関数
Shop.getSetOfCustomers()を実装してください。Shopおよびすべての関連クラスはShop.ktにあります。
Code
fun Shop.getSetOfCustomers(): Set<Customer> = customers.toSet()
Memo
Shop.ktで定義されているval customers: List<Customer>をSetに変換して取得する、という問題。問題文の通りtoSet()を呼び出すだけでOK。
data class Shop(val name: String, val customers: List<Customer>)