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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
matumoto
November 04, 2023
Technology
230
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
410
testingを眺める
matumoto
1
200
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
740
Goトランザクション処理
matumoto
1
79
いまいちどスライスの 挙動を見直してみる
matumoto
0
400
Go1.22のリリース予定の機能を見る
matumoto
0
83
Typed-nilについて
matumoto
0
370
GoのType Setsという概念
matumoto
0
49
GoのRateLimit処理の実装
matumoto
0
480
Other Decks in Technology
See All in Technology
AI時代の私の技術インプットとアウトプット術
tonkotsuboy_com
15
8k
long-running-tasks
cipepser
2
450
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
160
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
780
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
140
20260528_生成AIを専属DSに_Howの次にすべきことを考える
doradora09
PRO
0
270
Javaで学ぶSOLID原則
negima
1
240
Fabric-cicd によるAzure DevOps デプロイ
ryomaru0825
0
170
最低限これだけ押さえれ大丈夫_Claude Enterprise/Team企業展開ガバナンス入門
tkikuchi
1
570
テストコードのないプロジェクトにテストを根付かせる
tttol
1
240
組織の中で自分を経営する技術
shoota
0
230
Featured
See All Featured
Six Lessons from altMBA
skipperchong
29
4.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Are puppies a ranking factor?
jonoalderson
1
3.4k
Building the Perfect Custom Keyboard
takai
2
780
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
So, you think you're a good person
axbom
PRO
2
2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Deep Space Network (abreviated)
tonyrice
0
160
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
270
Exploring anti-patterns in Rails
aemeredith
3
380
A Soul's Torment
seathinner
6
2.9k
Paper Plane (Part 1)
katiecoart
PRO
0
8.1k
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
いかがでしたか??? ありがとうございました