LoginSignup
0
0

More than 1 year has passed since last update.

golangにおける関数の引数

Posted at

golangを勉強していて以下のような書き方を見て、よく分からなかったので調べてまとめてみようとおもいます

type Item struct{
  name  string
  price  init
}

func itempointer(i *Item){
  fmt.Println(*i)
}

golangにはポインタの概念が存在していて、関数の引数の型に値型や、ポインタ型を指定できます。
上のコードのように記述することで、構造体の要素の型をコピーしているんです。

短いですが、以上です。
何か間違いがございましたら、ご教示いただけますと幸いです。

【参考資料】

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