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
220
0
Share
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
380
testingを眺める
matumoto
1
190
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
700
Goトランザクション処理
matumoto
1
78
いまいちどスライスの 挙動を見直してみる
matumoto
0
400
Go1.22のリリース予定の機能を見る
matumoto
0
80
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
47
GoのRateLimit処理の実装
matumoto
0
470
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
6
18k
AWS認定資格は本当に意味があるのか?
nrinetcom
PRO
1
270
コードや知識を組み込む / Incorporate Code and Knowledge
ks91
PRO
0
140
Master Dataグループ紹介資料
sansan33
PRO
1
4.6k
Shipping AI Agents — Lessons from Production
vvatanabe
0
180
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
320
AI時代における技術的負債への取り組み
codenote
1
1.4k
Amazon S3 Filesについて
yama3133
2
210
こんなアーキテクチャ図はいやだ / Anti-pattern in AWS Architecture Diagrams
naospon
1
440
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
390
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
Code Interpreter で、AIに安全に コードを書かせる。
yokomachi
0
7.1k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Design in an AI World
tapps
0
190
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
260
Designing Powerful Visuals for Engaging Learning
tmiket
1
340
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
200
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
69
39k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
270
Crafting Experiences
bethany
1
110
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
いかがでしたか??? ありがとうございました