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
200
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
testingを眺める
matumoto
1
160
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
470
Goトランザクション処理
matumoto
1
52
いまいちどスライスの 挙動を見直してみる
matumoto
0
350
Go1.22のリリース予定の機能を見る
matumoto
0
69
Typed-nilについて
matumoto
0
330
GoのType Setsという概念
matumoto
0
29
GoのRateLimit処理の実装
matumoto
0
390
Webプッシュ通知触ってみた
matumoto
0
36
Other Decks in Technology
See All in Technology
コード1ミリもわからないけど Claude CodeでFigjamプラグインを作った話
abokadotyann
1
160
ソフトウェアエンジニアとデータエンジニアの違い・キャリアチェンジ
mtpooh
1
740
Datadog On-Call と Cloud SIEM で作る SOC 基盤
kuriyosh
0
150
AI時代に必要なデータプラットフォームの要件とは by @Kazaneya_PR / 20251107
kazaneya
PRO
4
950
Post-AIコーディング時代のエンジニア生存戦略
shinoyu
0
170
ubuntu-latest から ubuntu-slim へ移行しよう!コスト削減うれしい~!
asumikam
0
450
プロダクトエンジニアとしてのマインドセットの育み方 / How to improve product engineer mindset
saka2jp
2
210
Proxmox × HCP Terraformで始めるお家プライベートクラウド
lamaglama39
1
170
Pythonで構築する全国市町村ナレッジグラフ: GraphRAGを用いた意味的地域検索への応用
negi111111
8
3.3k
AI-ready"のための"データ基盤 〜 LLMOpsで事業貢献するための基盤づくり
ismk
0
150
仕様駆動 x Codex で 超効率開発
ismk
2
1.3k
開発者から見たLLMの進化 202511
ny7760
1
170
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Typedesign – Prime Four
hannesfritz
42
2.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Practical Orchestrator
shlominoach
190
11k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Faster Mobile Websites
deanohume
310
31k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
GitHub's CSS Performance
jonrohan
1032
470k
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
いかがでしたか??? ありがとうございました