エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Go by Example: Interfaces
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Go by Example: Interfaces
For our example we’ll implement this interface on rect and circle types. type rect struct { width... For our example we’ll implement this interface on rect and circle types. type rect struct { width, height float64 } type circle struct { radius float64 } To implement an interface in Go, we just need to implement all the methods in the interface. Here we implement geometry on rects. func (r rect) area() float64 { return r.width * r.height } func (r rect) perim() float64 { return 2*r.width + 2*r.he

