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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
180
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
610
Goトランザクション処理
matumoto
1
62
いまいちどスライスの 挙動を見直してみる
matumoto
0
370
Go1.22のリリース予定の機能を見る
matumoto
0
70
Typed-nilについて
matumoto
0
350
GoのType Setsという概念
matumoto
0
36
GoのRateLimit処理の実装
matumoto
0
450
Webプッシュ通知触ってみた
matumoto
0
38
Other Decks in Technology
See All in Technology
2026年、サーバーレスの現在地 -「制約と戦う技術」から「当たり前の実行基盤」へ- /serverless2026
slsops
2
190
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
1.9k
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
Meshy Proプラン課金した
henjin0
0
180
We Built for Predictability; The Workloads Didn’t Care
stahnma
0
130
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
410
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
160
データの整合性を保ちたいだけなんだ
shoheimitani
4
1.4k
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
0
280
SREのプラクティスを用いた3領域同時 マネジメントへの挑戦 〜SRE・情シス・セキュリティを統合した チーム運営術〜
coconala_engineer
2
540
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
160
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
420
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
130
The SEO Collaboration Effect
kristinabergwall1
0
350
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
150
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
55
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
400
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
430
Amusing Abliteration
ianozsvald
0
92
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
430
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
いかがでしたか??? ありがとうございました