Last active
October 11, 2017 16:30
-
-
Save inancgumus/05023157870c203038cef1419432c593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
// typed constant declaration | |
const Pi float64 = 3.14 | |
// multiple typed-constant declaration | |
const ( | |
Tau float64 = Pi * 2 | |
E float64 = 2.718 | |
) | |
// there is no short-declaration for constants | |
// because, a constant always needs to be initialized to a value | |
fmt.Println("Pi:", Pi, "\nTau:", Tau, "\nE:", E) | |
// NOTE: | |
// above declarations are for demonstration purposes. | |
// you can define them as untyped constants | |
// the compiler will automatically assign float64 to them | |
// | |
// by using, for example, 3.14's default-type of float, | |
// it will convert it to usual float64 type. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment