Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GoのUnderlying typeについて
Search
matumoto
November 04, 2023
Technology
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GoのUnderlying typeについて
2023/11/04 に行われた会津大学 学祭LTの資料です
イベントページはこちら
https://zli.connpass.com/event/298894/
matumoto
November 04, 2023
More Decks by matumoto
See All by matumoto
Go標準パッケージのI/O処理をながめる
matumoto
0
530
testingを眺める
matumoto
1
230
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
850
Goトランザクション処理
matumoto
1
100
いまいちどスライスの 挙動を見直してみる
matumoto
0
440
Go1.22のリリース予定の機能を見る
matumoto
0
100
Typed-nilについて
matumoto
0
410
GoのType Setsという概念
matumoto
0
69
GoのRateLimit処理の実装
matumoto
0
550
Other Decks in Technology
See All in Technology
バックオフィスに染み出すTypeScript ── clasp で安全に仕組みを作る
nealle
1
180
re:Invent の去年のスケジュールを公開します!
miu_crescent
PRO
0
270
渡米前の準備を制す!re:Invent 2026徹底準備術 / The Ultimate Preparation Guide for re:Invent 2026
yuj1osm
1
530
SLOを阻む不安
sraku2159
0
220
Maestro MCPとClaude Code Skillsによる自律的なE2Eテスト支援
asmz
0
410
視野はAIに、視座は人に / ai-for-breadth-humans-for-perspective
nkzn
6
2.9k
AIエージェント統制はAPIから——押さえるべき5つの要素
nagix
0
120
攻撃 3 時間 vs 復旧 10 時間。アクセスキー流出の非対称性を体感するために CTF を作った話
kazzpapa3
1
140
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
220
re:Invent2026 事前勉強会 歴史と愉しみ方10分LT編
toshi_atsumi
0
120
`go get`したらELFが降ってきた件
taiyow
0
160
(swiftc) NonCopyableとライフタイム修飾子
teamhimeh
0
170
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
WCS-LA-2024
lcolladotor
0
970
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
Mind Mapping
helmedeiros
1
430
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
400
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
670
Navigating Team Friction
lara
192
16k
HDC tutorial
michielstock
2
1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.7k
Prompt Engineering for Job Search
mfonobong
0
570
How to Ace a Technical Interview
jacobian
280
24k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
460
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
いかがでしたか??? ありがとうございました