1
Main.kt
1234567891011121314151617181920class Person(val name: String) { private val friends = mutableListOf<Person>() fun getFriends() : List<Person>{ return friends; } infix fun befriend(person: Person) { friends.add(person) println("${this.name} is now friends with ${person.name}") } } fun main() { val alice = Person("Alice") val bob = Person("Bob") alice befriend bob println(alice.getFriends()) }
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 1
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
AI Course Recommendation
This conversation will be available in the AI Assistant at the bottom-right corner of your My Home page.
AI Assistant
How can I help you?
Powered by 
Awesome!
Completion rate improved to 100
1
Swipe to show menu
Main.kt
1234567891011121314151617181920class Person(val name: String) { private val friends = mutableListOf<Person>() fun getFriends() : List<Person>{ return friends; } infix fun befriend(person: Person) { friends.add(person) println("${this.name} is now friends with ${person.name}") } } fun main() { val alice = Person("Alice") val bob = Person("Bob") alice befriend bob println(alice.getFriends()) }
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 1