Created
December 7, 2020 05:20
-
-
Save le0nidas/998a4574e50717e2dca39b33f0bda1d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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