0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Golang】標準パッケージ iota

Posted at

#【Golang】標準パッケージ iota
Golangの基礎学習〜Webアプリケーション作成までの学習を終えたので、復習を兼ねてまとめていく。 基礎〜応用まで。

package main
//iota
/*
連番を作ってくれる
*/

import "fmt"

//定数
//iota = 0から連番が代入される
const (
	c1 = iota
	c2
	c3
)

//
const (
	//0は使わない
	_      = iota
	//1の10回シフト 1024
	KB int = 1 << (10 * iota)
	//x1024=メガバイト
	MB
	//x1024x1024=ギガバイト
	GB
)

func main() {
	fmt.Println(c1, c2, c3)
	//>>0 1 2
	fmt.Println(KB, MB, GB)
	//>>1024 10488576 1073741824
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?