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
570
Goトランザクション処理
matumoto
1
59
いまいちどスライスの 挙動を見直してみる
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
First-Principles-of-Scrum
hiranabe
2
910
Java 25に至る道
skrb
3
130
田舎で20年スクラム(後編):一個人が企業で長期戦アジャイルに挑む意味
chinmo
1
870
AWSと生成AIで学ぶ!実行計画の読み解き方とSQLチューニングの実践
yakumo
2
110
テストセンター受験、オンライン受験、どっちなんだい?
yama3133
0
200
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
自己管理型チームと個人のセルフマネジメント 〜モチベーション編〜
kakehashi
PRO
5
1.1k
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.5k
Qiita Bash アドカレ LT #1
okaru
0
150
RALGO : AIを組織に組み込む方法 -アルゴリズム中心組織設計- #RSGT2026 / RALGO: How to Integrate AI into an Organization – Algorithm-Centric Organizational Design
kyonmm
PRO
3
480
松尾研LLM講座2025 応用編Day3「軽量化」 講義資料
aratako
15
4.8k
善意の活動は、なぜ続かなくなるのか ーふりかえりが"構造を変える判断"になった半年間ー
matsukurou
0
180
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
3
35k
Automating Front-end Workflow
addyosmani
1371
200k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Amusing Abliteration
ianozsvald
0
80
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
250
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
2
76
Test your architecture with Archunit
thirion
1
2.1k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
37
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
43
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Prompt Engineering for Job Search
mfonobong
0
140
The Language of Interfaces
destraynor
162
26k
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
いかがでしたか??? ありがとうございました