<@U5N7WE3B7> ``` interface Populace { val peop...
# getting-started
c
@chb0kotlin
Copy code
interface Populace {
   val people: Set<People>
}
c
Can I do better:
Copy code
interface Populace {

    val people : Set<People>
    fun getPopulation() : Int

}

data class People(val age:Int, val givenName:String, val surname:String)

class CompositePopulace(private val populi:Set<Populace>) : Populace {


    override val people by lazy {
        populi.flatMap { it.people }.toSet()
    }


    override fun getPopulation(): Int = people.size
}
c
population
should be a property too
otherwise looks good
(I would also not call it
population
, more like
size
)
c
final:
Copy code
interface Populace {

    val people : Set<People>
    val size : Int

}

data class People(val age:Int, val givenName:String, val surname:String)

class CompositePopulace(private val populi:Set<Populace>) : Populace {


    override val people by lazy {
        populi.map { it.people }.reduce { s,t -> s union t }
    }


    override val size = people.size
}
Thanks for the help
I have been evangelizing this at work