Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GoのUnderlying typeについて
Search
matumoto
November 04, 2023
Technology
0
210
GoのUnderlying typeについて
2023/11/04 に行われた会津大学 学祭LTの資料です
イベントページはこちら
https://zli.connpass.com/event/298894/
matumoto
November 04, 2023
Tweet
Share
More Decks by matumoto
See All by matumoto
testingを眺める
matumoto
1
170
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
580
Goトランザクション処理
matumoto
1
60
いまいちどスライスの 挙動を見直してみる
matumoto
0
370
Go1.22のリリース予定の機能を見る
matumoto
0
70
Typed-nilについて
matumoto
0
350
GoのType Setsという概念
matumoto
0
33
GoのRateLimit処理の実装
matumoto
0
440
Webプッシュ通知触ってみた
matumoto
0
38
Other Decks in Technology
See All in Technology
業務の煩悩を祓うAI活用術108選 / AI 108 Usages
smartbank
9
22k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.2k
First-Principles-of-Scrum
hiranabe
4
2.1k
AI Agent Standards and Protocols: a Walkthrough of MCP, A2A, and more...
glaforge
0
270
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
520
ソフトとハード両方いけるデータ人材の育て方
waiwai2111
1
200
アウトプットはいいぞ / output_iizo
uhooi
0
110
手軽に作れる電卓を作って イベントソーシングに親しもう CQRS+ESカンファレンス2026
akinoriakatsuka
0
260
AI に「学ばせ、調べさせ、作らせる」。Auth0 開発を加速させる7つの実践的アプローチ
scova0731
0
270
「アウトプット脳からユーザー価値脳へ」がそんなに簡単にできたら苦労しない #RSGT2026
aki_iinuma
11
5.2k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
62k
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
140
How to build a perfect <img>
jonoalderson
1
4.8k
The SEO Collaboration Effect
kristinabergwall1
0
330
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Limits of Empathy - UXLibs8
cassininazir
1
200
ラッコキーワード サービス紹介資料
rakko
0
2M
HDC tutorial
michielstock
1
320
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
180
Transcript
GoのUnderlying typeとは? どんなもの?なに? 彼女はいるの?調べてみました! 2023/11/04 学祭LT matumoto
• 学年:28期 • 趣味: ◦ マイクラ ◦ PokemonSleep ◦ VTuber
▪ 叶 ▪ やしきず • Twitter:@matumoto_1234 • ひとこと:マイクラに生活を破壊された matumoto 松本 響輝 自己紹介
Goの文法おさらい
Goの型エイリアス • type B = A でAを元にエイリアスを宣言できる
Goの型定義 • type B A でAを元に型を定義できる
型定義した型へのメソッド
関数とジェネリクス • 関数に型パラメータを取らせることができる
ジェネリクスの型制約 • 型パラメータに対して、型制約をかけることができる • 下のPrint関数の型引数にはintかstringしか渡せない
型制約のapproximation element • ~Tという文法で型Tを元にした型として、型制約の要素に使える
型制約のapproximation element • MyIntなどintを元にした型を渡すことができる
本題
Underlying typeとは? • 代入可能性やジェネリクスにおいての重要な概念 • すべての型はunderlying typeをちょうど一つ持つ
underlying の意味 •
例 • MyIntのunderlying typeはint
例 • intのunderlying typeはint
4つのルールによって決まる
クイズ
クイズ • MyMyStringのunderlying typeは?
正解 • 型定義はunderlying typeを共有するので、正解はstring
クイズ • struct{ x int }のunderlying typeは?
正解 • 型リテラルのunderlying typeはそれ自身
クイズ • MyIntsのunderlying typeは?
正解 • 型宣言はunderlying typeを共有するので、MyIntsのunderlying typeは[]MyIntの underlying type • 型リテラル[]MyIntのunderlying typeはそれ自身
• よって、MyIntsのunderlying typeは[]MyInt
いかがでしたか??? ありがとうございました