MyTetra Share
Делитесь знаниями!
Время создания: 01.10.2017 14:51
Раздел: Go
Запись: xintrea/mytetra_db_mcold/master/base/1506858674206ajktmum/text.html на

The const Keyword

You can use const prefix to declare constants with a specific type as follows −

const variable type = value;

The following example shows how to use the const keyword −

package main

import "fmt"

func main() {
   const LENGTH int = 10
   const WIDTH int = 5   
   var area int

   area = LENGTH * WIDTH
   fmt.Printf("value of area : %d", area)   

When the above code is compiled and executed, it produces the following result −

value of area : 50

Note that it is a good programming practice to define constants in CAPITALS.

MyTetra Share v.0.58
Яндекс индекс цитирования