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
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
Oracle Cloud Infrastructure:2026年5月度サービス・アップデート
oracle4engineer
PRO
1
280
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
110
食べログのサーキットブレーカー導入を振り返って
atpons
1
160
Claude code Orchestra
ozakiomumkj
3
780
Terraformモジュールは、なぜ「魔境」化するのか
hayama17
1
130
海外カンファレンス「JavaOne」参加レポート ユーザー系IT企業における目的・成果/JavaOne Report Purpose and Results in the User IT Company
muit
0
120
OpenID Connectによるサービス間連携
takesection
0
150
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
140
Anthropic AIネイティブ・スタートアップ構築のプレイブック を理解する
nagatsu
0
230
Agentic AI時代における メルカリのAIガバナンスとガードレール実装
naoichihara
17
17k
管理アカウント単一運用からAWS Organizationsに移行するの大変で滅
hiramax
0
350
AIが変えた"品質の守り方"
kkakizaki
13
5.5k
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
760
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
370
4 Signs Your Business is Dying
shpigford
187
22k
Building AI with AI
inesmontani
PRO
1
1k
Embracing the Ebb and Flow
colly
88
5.1k
Designing for humans not robots
tammielis
254
26k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
130
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
190
Believing is Seeing
oripsolob
1
140
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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
いかがでしたか??? ありがとうございました