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
590
Goトランザクション処理
matumoto
1
61
いまいちどスライスの 挙動を見直してみる
matumoto
0
370
Go1.22のリリース予定の機能を見る
matumoto
0
70
Typed-nilについて
matumoto
0
350
GoのType Setsという概念
matumoto
0
34
GoのRateLimit処理の実装
matumoto
0
440
Webプッシュ通知触ってみた
matumoto
0
38
Other Decks in Technology
See All in Technology
形式手法特論:コンパイラの「正しさ」は証明できるか? #burikaigi / BuriKaigi 2026
ytaka23
17
6.3k
純粋なイミュータブルモデルを設計してからイベントソーシングと組み合わせるDeciderの実践方法の紹介 /Introducing Decider Pattern with Event Sourcing
tomohisa
1
1.2k
旬のブリと旬の技術で楽しむ AI エージェント設計開発レシピ
chack411
1
290
手軽に作れる電卓を作って イベントソーシングに親しもう CQRS+ESカンファレンス2026
akinoriakatsuka
0
460
Java 25に至る道
skrb
3
230
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
GitHub Copilot CLI 現状確認会議
torumakabe
8
2.4k
SOC2は、取った瞬間よりその後が面白い
3flower
0
110
AI Agent Agentic Workflow の可観測性 / Observability of AI Agent Agentic Workflow
yuzujoe
4
2.1k
ソフトとハード両方いけるデータ人材の育て方
waiwai2111
1
490
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3.7k
Web Intelligence and Visual Media Analytics
weblyzard
PRO
1
6.8k
Featured
See All Featured
Test your architecture with Archunit
thirion
1
2.1k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
1
230
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
140
Measuring & Analyzing Core Web Vitals
bluesmoon
9
730
My Coaching Mixtape
mlcsv
0
26
We Have a Design System, Now What?
morganepeng
54
8k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
180
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
99
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Designing Experiences People Love
moore
143
24k
Thoughts on Productivity
jonyablonski
74
5k
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
いかがでしたか??? ありがとうございました