[1725989] | 1 | package main |
---|
| 2 | import "fmt" |
---|
| 3 | |
---|
| 4 | // const R int = 0; |
---|
| 5 | // const G uint = 1; |
---|
| 6 | // const B = 2; |
---|
| 7 | // const Fred = "Fred"; |
---|
| 8 | // const Mary = "Mary"; |
---|
| 9 | // const Jane = "Jane"; |
---|
| 10 | // const S = 0; |
---|
| 11 | // const T = 0; |
---|
| 12 | // const USA = "USA"; |
---|
| 13 | // const U = "USA"; |
---|
| 14 | // const V = 3.1; |
---|
| 15 | // const W = 3.1; |
---|
| 16 | // |
---|
| 17 | // func main() { |
---|
| 18 | // fmt.Println( Mon, Tue, Wed ) |
---|
| 19 | // } // main |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | const ( R = 0; G = 3; B ) // implicit: 0 0 0 |
---|
| 23 | const ( Fred = "Fred"; Mary = "Mary"; Jane = "Jane" ) // Fred Mary Jane |
---|
| 24 | const ( H = 0; Jack = "Jack"; J; K = 0; I ) // type change, implicit: 0 Jack Jack |
---|
| 25 | const ( C = iota + G; M = iota; Y ) |
---|
| 26 | const ( Mon = iota; Tue; Wed; // 0, 1, 2 |
---|
| 27 | Thu = 10; Fri = iota - Wed + Thu - 1; Sat; Sun = iota ) // 10, 11, 12, 13 |
---|
| 28 | const ( O1 = iota + 1; _; O3; _; O5 ) // 1, 3, 5 |
---|
| 29 | const ( V1 = iota; V2; V3 = 7; V4 = iota + 1; V5 ) |
---|
| 30 | const ( S = 0; T; USA = "USA"; U; V = 3.1; W ) |
---|
| 31 | const ( D = 1.5; E ); |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | func main() { |
---|
| 36 | if 3 == R {}; |
---|
| 37 | fmt.Println( R, G, B ) |
---|
| 38 | fmt.Println( Fred, Mary, Jane ) |
---|
| 39 | fmt.Println( H, Jack, J, K, I ) |
---|
| 40 | fmt.Println( C, M, Y ) |
---|
| 41 | fmt.Println( Mon, Tue, Wed, Thu, Fri, Sat, Sun ) |
---|
| 42 | fmt.Println( O1, O3, O5 ) |
---|
| 43 | fmt.Println( V1, V2, V3, V4, V5 ) |
---|
| 44 | fmt.Println( S, T, USA, U, V, W ) |
---|
| 45 | |
---|
| 46 | day := Mon; |
---|
| 47 | switch day { |
---|
| 48 | case Mon, Tue, Wed, Thu, Fri: |
---|
| 49 | fmt.Println( "weekday" ); |
---|
| 50 | case Sat, Sun: |
---|
| 51 | fmt.Println( "weekend" ); |
---|
| 52 | } |
---|
| 53 | for i := Mon; i <= Sun; i += 1 { |
---|
| 54 | fmt.Println( i ) |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | var ar[Sun] int |
---|
| 58 | ar[Mon] = 3 |
---|
| 59 | } // main |
---|