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
240
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
440
testingを眺める
matumoto
1
220
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
790
Goトランザクション処理
matumoto
1
87
いまいちどスライスの 挙動を見直してみる
matumoto
0
420
Go1.22のリリース予定の機能を見る
matumoto
0
90
Typed-nilについて
matumoto
0
380
GoのType Setsという概念
matumoto
0
62
GoのRateLimit処理の実装
matumoto
0
500
Other Decks in Technology
See All in Technology
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
190
取引先から届く 「セキュリティチェックシート」の読み解き方
kamadamakoto
0
140
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
変化の早いClaude Codeを 書籍に落とし込む
oikon48
7
1.4k
Genie Codeハンズオン基礎編
taka_aki
1
110
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
280
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
1
390
Software Supply Chain Attackからクラウド環境を守るためにできること
lhazy
2
250
【AG-UI × A2UI × MCP Apps】Generative UIをやさしく解説する
nrinetcom
PRO
1
110
ラジオの科学
frievea
0
300
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
950
The Cult of Friendly URLs
andyhume
79
7k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Unsuck your backbone
ammeep
672
58k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Automating Front-end Workflow
addyosmani
1369
210k
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
いかがでしたか??? ありがとうございました