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のinterface型

Posted at

interface型

  • あらゆる型と互換性のある型
  • Objectクラスのようなもの
  • あくまで、全ての型の値を汎用的に表すものなので、演算などはできない
main.go
package main

import (
    "fmt"
)

func main() {
    var x interface{}
    fmt.Printf("%#v", x)
}

出力すると、となる。
int型では0が初期値としてセットされるが、interface型ではnilとなる

$ go run main.go 
<nil>
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?