• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Class.this.. ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class.this.. ?


  • Subject: Re: Class.this.. ?
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Tue, 28 Oct 2008 22:00:39 -0400


On Oct 28, 2008, at 19:33, Q wrote:

NestingClass.ref

That would refer to a static variable called 'ref' on the class NestingClass.

LOL! Obviously! I can't believe I overlooked that 'minor' issue :)

This is a no-go. Now, as far as I understand the concept of class nesting as it is implemented in Java, this should work.

For inner classes there are two possible meanings for 'this', which is why the ClassName.this syntax exists, so that you can access both of them. Outside the context of an instance method on the inner class you cannot access the instance of the nesting class directly.


After all, it is simple to make a method in the inner class that will expose the instance of the nesting class by returning NestingClass.this.

This is what you will need to do.

Well, the duality of 'this' aside, being able to access easily the nesting class instance is quite handy, within the inner class or without. However, I guess the fact that obtaining it outside the inner class code is not required often does not warrant coming up with some way to formulate it syntactically, especially since there is such an easy way to expose it. Still, I've found it an interesting thought.


Cheers,
F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Class.this.. ? (From: Florijan Stamenkovic <email@hidden>)
 >Re: Class.this.. ? (From: Q <email@hidden>)

  • Prev by Date: Re: Object Store Coordinator and User Info – Is this Dangerous?
  • Next by Date: Re: Object Store Coordinator and User Info – Is this Dangerous?
  • Previous by thread: Re: Class.this.. ?
  • Next by thread: java.lang.ClassNotFoundException: org.objectstyle.woproject.ant.WOFramework
  • Index(es):
    • Date
    • Thread