Skip to content

Instantly share code, notes, and snippets.

@Sottti
Last active December 3, 2018 07:11
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 Sottti/91dc0f7bf60ac7581b012ea401ca21d0 to your computer and use it in GitHub Desktop.
Save Sottti/91dc0f7bf60ac7581b012ea401ca21d0 to your computer and use it in GitHub Desktop.
// Protected.kt file
// Visible inside this file
private const val numberThree = 3
// Visible inside this file
private open class User() {
// Visible inside the User class and subclasses
protected val numberEight = numberThree.plus(5)
}
// Visible inside this file
private class Moderator() : User() {
// Visible inside the Moderator class
// numberEight is visible because Moderator is a subclass of User
private val numberEleven = numberThree.plus(numberEight)
}
// ERROR: protected modifier is not allowed for top level declarations
protected const val numberThree = 3
// ERROR: protected modifier is not allowed for top level declarations
protected class Staff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment