Skip to content

Instantly share code, notes, and snippets.

@praveenKajla
Created September 5, 2017 06:51
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 praveenKajla/4e2e591556ced328c357c790d9a364c9 to your computer and use it in GitHub Desktop.
Save praveenKajla/4e2e591556ced328c357c790d9a364c9 to your computer and use it in GitHub Desktop.
package readinglist
class DirectoryExplorer(val user:String){
inner class PermissionCheck(){
fun validatePermission(){
}
}
fun listFolder(folder:String, user:String){
val permissionCheck = PermissionCheck()
permissionCheck.validatePermission()
}
}
fun main(args: Array<String>) {
val dir = DirectoryExplorer()
val pc = DirectoryExplorer().PermissionCheck()
}
package readinglist
class DirectoryExplorer(){
class PermissionCheck(){
fun validatePermission(user:String){
}
}
fun listFolder(folder:String, user:String){
val permissionCheck = PermissionCheck()
permissionCheck.validatePermission(user)
}
}
fun main(args: Array<String>) {
val dir = DirectoryExplorer()
val pc = DirectoryExplorer.PermissionCheck()
}
//kotlin allows me to access nested classes
//If i dont want to i can declare nested class as private
//we can access this nested class from java too
//DirectoryExplorer.PermissionCheck pc = new DirectoryExplorer.PermissionCheck()
//Now what if i want to access property of external class in nested class
//which is not possible by default . In order to do so define the nested class as
//a inner class
//but then i cant access nested class as DirectoryExplorer.PermissionCheck()
//since now nested class has becoome pasrt of the external class insatnce
//hence we would have to do DirectoryExplorer().PermissionCheck()
@praveenKajla
Copy link
Author

//kotlin allows me to access nested classes
//If i dont want to i can declare nested class as private

//we can access this nested class from java too
//DirectoryExplorer.PermissionCheck pc = new DirectoryExplorer.PermissionCheck()

//Now what if i want to access property of external class in nested class
//which is not possible by default . In order to do so define the nested class as
//a inner class
//but then i cant access nested class as DirectoryExplorer.PermissionCheck()
//since now nested class has becoome pasrt of the external class insatnce
//hence we would have to do DirectoryExplorer().PermissionCheck()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment