Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Outer Class Keyword  RSS feed

 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gotten hundreds of lines of code to useable state.

One prototyping issue I ignored for the sake of get going was passing a file to a print, because there would be two files to print off of the same Collection.

The author, very accomplished, made the print an inner class.

What I *really* need to do is address the outer-class (correctly), which will be an instance variable or execution path would not be at this point anyway.

I just want to be careful, for this deeply-nested / processor-intensive loop.

  • outer is a keyword, correct
  • outer.WordCount.fileVar would address the outer class WordCount's variable named fileVar - correct ? Or do I address the outer class by name.
  • Making the inner class final might allow the compiler to do some optomizations, correct ?
  • It is a heavily modified David Eck's Javanotes WordCount
     
    Keith Lynn
    Ranch Hand
    Posts: 2409
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No, outer is not a keyword.

    From within an inner class you can access the outer class's this by outerClassName.this
     
    Nicholas Jordan
    Ranch Hand
    Posts: 1282
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you. I will get it fixed tonight.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!