From 33393338c62f8542fcbfdc9debd519343737d92e Mon Sep 17 00:00:00 2001 From: hegdeashwin Date: Sat, 20 Jun 2015 17:41:14 +0530 Subject: [PATCH] adds constants eg --- codes/session-1/constants.go | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 codes/session-1/constants.go diff --git a/codes/session-1/constants.go b/codes/session-1/constants.go new file mode 100644 index 0000000..e432dfe --- /dev/null +++ b/codes/session-1/constants.go @@ -0,0 +1,63 @@ +package main + +import "fmt" + +/** + * Define constants + * Float, String and iota (incremental) + */ +const ( + PI = 3.14 + LANGUAGE = "Go" + + A = iota + B = iota + C = iota +) + +/** + * Define constants iota (incremental) + */ +const ( + P = iota + Q = iota + R = iota +) + +/** + * Define constants iota (incremental) + * Here, Y and Z does has type, so Go will assume Y and Z are of type iota from X + */ +const ( + X = iota + Y + Z +) + +func main() { + + /** + * OUTPUT: 3.14 + */ + fmt.Println(PI) + + /** + * OUTPUT: Go + */ + fmt.Println(LANGUAGE) + + /** + * OUTPUT: 2 3 4 + */ + fmt.Println(A, B, C) + + /** + * OUTPUT: 0 1 2 + */ + fmt.Println(P, Q, R) + + /** + * OUTPUT: 0 1 2 + */ + fmt.Println(X, Y, Z) +} \ No newline at end of file