Class static blocks

Michael O'Brien mob at mbedthis.com
Sun Apr 20 11:52:58 PDT 2008


I wanted to clarify the meaning of a static block. Consider:

class Shape {

	static var count
	var origin

	static {
		//	Is this static initialization code?

		count = 1
	}

	{

		//	Is this instance initialization code?

		origin = 0		
	}
}


Reading the latest draft of the grammar I'm assuming that you must now  
put static init code inside a static {} block. Is this correct?

Does that mean that other directives outside of methods and static  
blocks are instance initialization code?  If so, does it run before or  
after the constructor code?

Michael

	



More information about the Es4-discuss mailing list