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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
460
testingを眺める
matumoto
1
220
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
800
Goトランザクション処理
matumoto
1
91
いまいちどスライスの 挙動を見直してみる
matumoto
0
430
Go1.22のリリース予定の機能を見る
matumoto
0
92
Typed-nilについて
matumoto
0
390
GoのType Setsという概念
matumoto
0
62
GoのRateLimit処理の実装
matumoto
0
510
Other Decks in Technology
See All in Technology
Microsoft MVP プログラムを紹介するから目指す人増えてくれ
tsubakimoto_s
0
160
現場の暗黙知を継承するAIエージェント — 対話から生まれる長期記憶と Skills
atsukish
0
190
AWSとGitHub Actionsの責任境界と 組織で安全に使用する取り組み
nealle
1
240
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
25k
【Oracle AI Spotlight ウェビナー】AWSか、Azureか、Google Cloudか。その議論にオラクルを含める意義。
oracle4engineer
PRO
1
110
わたしが知り合いゼロの勉強会に 行けるようになるまで
r5ni4
2
850
AIレビュー時代に必要なのは、SLOで引く撤退ライン
nobuoooo
0
160
承認ゲートは何を守っているのか? AIエージェントの自律購入を実測した結果
yama3133
1
100
dbt と Snowflake と tag
kevinrobot34
2
310
IHV like なユースケースへのOpenID Connect 関連仕様の適用事例
optim
0
410
AI時代のデータ基盤を考える問い
pacocat
0
780
Claude Codeで開発以外の業務も爆速化しよう!
minorun365
PRO
12
9.3k
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
560
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
The Curse of the Amulet
leimatthew05
2
14k
WCS-LA-2024
lcolladotor
0
810
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
4 Signs Your Business is Dying
shpigford
187
23k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
220
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
310
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
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
いかがでしたか??? ありがとうございました