Skip to content

Instantly share code, notes, and snippets.

@Serchinastico
Created September 17, 2018 15:49
Show Gist options
  • Save Serchinastico/c32415481a73e2b462531d357e4d1d0f to your computer and use it in GitHub Desktop.
Save Serchinastico/c32415481a73e2b462531d357e4d1d0f to your computer and use it in GitHub Desktop.
filter;map koan
// Return the set of cities the customers are from
fun Shop.getCitiesCustomersAreFrom(): Set<City> = customers.map { it.city }.toSet()
// Return a list of the customers who live in the given city
fun Shop.getCustomersFrom(city: City): List<Customer> = customers.filter { it.city == city }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment