はじめに
Kotlin勉強中の時にわからない単語などを調べてまとめていく
内容
// Return true if all customers are from the given city
// 全部条件に合うか。一つでも合わなければfalse
fun Shop.checkAllCustomersAreFrom(city: City): Boolean = customers.all{it.city == city}
// Return true if there is at least one customer from the given city
// 一つでも条件に合うか。合えばtrue
fun Shop.hasCustomerFrom(city: City): Boolean = customers.any{it.city == city}
// Return the number of customers from the given city
// いくつ条件にあっているか
fun Shop.countCustomersFrom(city: City): Int = customers.count {it.city == city}
// Return a customer who lives in the given city, or null if there is none
// 条件にあった最初の要素を返す
fun Shop.findAnyCustomerFrom(city: City): Customer? = customers.find{it.city == city}