-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants02.go
More file actions
37 lines (28 loc) · 944 Bytes
/
constants02.go
File metadata and controls
37 lines (28 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Alta3 Research | Author: RZFeeser
Constants - Introduction to numerical constants */
package main
import "fmt"
// this is a group of constants being declared at once
const (
Code = 585 // go will determine this is a "untyped" integer
Big = "New York"
Country = "USA"
)
func oven(i string) {
return
}
func main() {
// display our global constants
fmt.Println(Big) // displays New York
fmt.Println(Country) // displays USA
// Note: constants may also be lower case
// they do not have to be uppercase
const Small = 3 // this is an "untyped" integer
fmt.Println(Small)
// if uncommented, this will fail
// Small = 10 // reassignment is NOT allowed
// if uncommented, this will fail
// the value of constants needs to be known at compile time
// therefore values returned by function calls are illegal
// const cupcake = oven("vanilla")
}