From: Rob Pike Date: Tue, 15 Jul 2008 22:27:31 +0000 (-0700) Subject: improve the examples in the section on iota X-Git-Tag: weekly.2009-11-06~3488 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1401c110083a38fab5ab396ff2d8e33c40f70af2;p=gostls13.git improve the examples in the section on iota SVN=127347 --- diff --git a/doc/go_lang.txt b/doc/go_lang.txt index 2f102c06cc..875f7b2d11 100644 --- a/doc/go_lang.txt +++ b/doc/go_lang.txt @@ -1499,6 +1499,22 @@ a set of related constants: const x = iota; // sets x to 0 const y = iota; // sets y to 0 +Since the expression in constant declarations repeats implicitly +if omitted, the first two examples above can be abbreviated: + + const ( + enum0 = iota; // sets enum0 to 0, etc. + enum1; + enum2 + ) + + const ( + a = 1 << iota; // sets a to 1 (iota has been reset) + b; // sets b to 2 + c; // sets c to 4 + ) + + TODO: should iota work in var, type, func decls too?