Re: Class.this.. ?
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