I'm currently teaching myself Kotlin and am a bit confused at how visibility is working.
class Test(val name: String) {
private fun sayName() {
println(name)
}
fun askName(test: Test) {
test.sayName()
}
}
val test1 = Test("one")
val test2 = Test("two")
test1.askName(test2)
The result is "two". Why am I able to access the private method of another instance? Shouldn't the sayName() method only be accessible from within its own instance?