Access Modifier (접근 변경자)

  • public
  • private
  • protected
  • internal
//private 최상위 프로퍼티
private var index = 0

//private class
private class Animal(val name: String)

//private function
private fun recordAnimal(
  animal: Animal
) {
  println("Animal #$index: ${animal.name}")
  index++
}

fun recordAnimals() {
  recordAnimal(Animal("Tiger"))
  recordAnimal(Animal("Lion"))
}

fun recordAnimalsCount() {
  println("$index animals are here!")
}

댓글남기기