Skip to content

Commit d9bc69e

Browse files
author
Ashwin Hegde
committed
Merge pull request #13 from hegdeashwin/develop
adds constants eg
2 parents fa48013 + 3339333 commit d9bc69e

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

codes/session-1/constants.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package main
2+
3+
import "fmt"
4+
5+
/**
6+
* Define constants
7+
* Float, String and iota (incremental)
8+
*/
9+
const (
10+
PI = 3.14
11+
LANGUAGE = "Go"
12+
13+
A = iota
14+
B = iota
15+
C = iota
16+
)
17+
18+
/**
19+
* Define constants iota (incremental)
20+
*/
21+
const (
22+
P = iota
23+
Q = iota
24+
R = iota
25+
)
26+
27+
/**
28+
* Define constants iota (incremental)
29+
* Here, Y and Z does has type, so Go will assume Y and Z are of type iota from X
30+
*/
31+
const (
32+
X = iota
33+
Y
34+
Z
35+
)
36+
37+
func main() {
38+
39+
/**
40+
* OUTPUT: 3.14
41+
*/
42+
fmt.Println(PI)
43+
44+
/**
45+
* OUTPUT: Go
46+
*/
47+
fmt.Println(LANGUAGE)
48+
49+
/**
50+
* OUTPUT: 2 3 4
51+
*/
52+
fmt.Println(A, B, C)
53+
54+
/**
55+
* OUTPUT: 0 1 2
56+
*/
57+
fmt.Println(P, Q, R)
58+
59+
/**
60+
* OUTPUT: 0 1 2
61+
*/
62+
fmt.Println(X, Y, Z)
63+
}

0 commit comments

Comments
 (0)