Delegates and nested classes...
    Tom S 
    h3r3tic at remove.mat.uni.torun.pl
       
    Sun May 21 07:00:18 PDT 2006
    
    
  
Markus Dangl wrote:
> I expected the following code to print "Hello", but it doesn't. Since a 
> nested class has access to its enclosing classes' members, i assumed it 
> could also return delegates to its methods. Where am i wrong - or is it 
> a bug?
Looks like a bug to me... you could try the following workaround:
class Foo
{
	Foo outer() { return this; }
	
	...
	class Bar {
		void delegate() getDelegate()
		{
			return &outer.sayHello;
		}
	}
	
	...
}
-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d-pu s+: a-->----- C+++$>++++ UL P+ L+ E--- W++ N++ o? K? w++ !O 
!M V? PS- PE- Y PGP t 5 X? R tv-- b DI- D+ G e>+++ h>++ !r !y
------END GEEK CODE BLOCK------
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/
    
    
More information about the Digitalmars-d-learn
mailing list