Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created December 7, 2020 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/998a4574e50717e2dca39b33f0bda1d5 to your computer and use it in GitHub Desktop.
Save le0nidas/998a4574e50717e2dca39b33f0bda1d5 to your computer and use it in GitHub Desktop.
// Person.kt
class Person(
val name: String,
val surname: String
)
// PeopleScreen.kt
class PeopleScreen(
private val people: List<Person>
) {
fun render() {
people.forEachIndexed { index, person ->
println("${index + 1}. ${person.name}, ${person.surname}")
}
}
}
// Usage:
fun main() {
val people = listOf(
Person("Joe", "Dow"),
Person("Jill", "Doe"),
Person("Jack", "Black")
)
val screen = PeopleScreen(people)
screen.render()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment