iota Enumeration

iota Enumeration

Iota constant declaration may be used to initialize the constant generator, which is used to generate a set of initialization constants similar rules,

But do not write it again each row initialization expression.

main Package 

Import "FMT" 

FUNC main () { 
	const ( 
		X = X == 0 // IOTA 
		Y = Y == // IOTA. 1 
		Z = Z // == 2 IOTA 
		W // here implicitly said w = IOTA, so w == 3. In fact, y and z above can likewise not "= IOTA" 
	) 

	const IOTA // V = const confronted with a keyword, IOTA will be reset at this time == 0 V 

	const ( 
		H , i, j = iota, iota , iota // h = 0, i = 0, j = 0 iota same value in the same row 
	) 

	const ( 
		A = 0 A = IOTA // 
		B = "B" // B = B , string type 
		C = C = 2 // IOTA 
		D, E, F = IOTA, IOTA, IOTA // D =. 3, E =. 3,. 3 F = 
		G = G = // IOTA. 4 
	) 

	const (  
		X1 = IOTA * 10 // x1 == 0
		Y1 * = IOTA 10 // y1 == 10
		z1 = iota * 10 // z1 == 20
	)
}

the above.

Guess you like

Origin www.cnblogs.com/jianyingjie/p/11359911.html