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
170
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
Goトランザクション処理
matumoto
0
34
いまいちどスライスの 挙動を見直してみる
matumoto
0
310
Go1.22のリリース予定の機能を見る
matumoto
0
58
Typed-nilについて
matumoto
0
250
GoのType Setsという概念
matumoto
0
17
GoのRateLimit処理の実装
matumoto
0
280
Webプッシュ通知触ってみた
matumoto
0
31
拡張ユークリッドの互除法の紹介
matumoto
0
220
Goでの楕円曲線暗号の実装
matumoto
0
33
Other Decks in Technology
See All in Technology
AIエージェント開発手法と業務導入のプラクティス
ykosaka
7
1.8k
JPOUG Tech Talk #12 UNDO Tablespace Reintroduction
nori_shinoda
2
150
AWS全冠芸人が見た世界 ~資格取得より大切なこと~
masakiokuda
5
6.4k
LiteXとオレオレCPUで作る自作SoC奮闘記
msyksphinz
0
740
DETR手法の変遷と最新動向(CVPR2025)
tenten0727
2
1.4k
Amazon CloudWatch を使って NW 監視を行うには
o11yfes2023
0
170
Terraform Cloudで始めるおひとりさまOrganizationsのすゝめ
handy
2
190
Road to Go Gem #rubykaigi
sue445
0
910
CodePipelineのアクション統合から学ぶAWS CDKの抽象化技術 / codepipeline-actions-cdk-abstraction
gotok365
5
290
AIコーディングの最前線 〜活用のコツと課題〜
pharma_x_tech
4
2.3k
技術者はかっこいいものだ!!~キルラキルから学んだエンジニアの生き方~
masakiokuda
2
270
バックオフィス向け toB SaaS バクラクにおけるレコメンド技術活用 / recommender-systems-in-layerx-bakuraku
yuya4
6
560
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Pragmatic Product Professional
lauravandoore
33
6.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Designing for Performance
lara
608
69k
A designer walks into a library…
pauljervisheath
205
24k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
How to train your dragon (web standard)
notwaldorf
90
6k
How to Ace a Technical Interview
jacobian
276
23k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
23
2.6k
Optimising Largest Contentful Paint
csswizardry
36
3.2k
Typedesign – Prime Four
hannesfritz
41
2.6k
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
いかがでしたか??? ありがとうございました