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
220
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標準パッケージのI/O処理をながめる
matumoto
0
250
testingを眺める
matumoto
1
190
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
670
Goトランザクション処理
matumoto
1
77
いまいちどスライスの 挙動を見直してみる
matumoto
0
390
Go1.22のリリース予定の機能を見る
matumoto
0
79
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
46
GoのRateLimit処理の実装
matumoto
0
460
Other Decks in Technology
See All in Technology
GitHub Copilot CLI で Azure Portal to Bicep
tsubakimoto_s
0
170
JEDAI認定プログラム JEDAI Order 2026 受賞者一覧 / JEDAI Order 2026 Winners
databricksjapan
0
180
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
3
13k
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
740
Phase11_戦略的AI経営
overflowinc
0
860
Kiroで見直す開発プロセスとAI-DLC
k_adachi_01
0
110
AI時代のオンプレ-クラウドキャリアチェンジ考
yuu0w0yuu
0
200
Cortex Code CLI と一緒に進めるAgentic Data Engineering
__allllllllez__
0
590
俺の/私の最強アーキテクチャ決定戦開催 ― チームで新しいアーキテクチャに適合していくために / 20260322 Naoki Takahashi
shift_evolve
PRO
1
380
Visional 28新卒プロダクト職(エンジニア/デザイナー)向け 会社説明資料 / Visional Company Briefing for Newgrads 28
visional_engineering_and_design
1
110
Kiro Meetup #7 Kiro アップデート (2025/12/15〜2026/3/20)
katzueno
2
200
A4)シラバスを超えて語る、テストマネジメント
moritamasami
0
110
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
150
How to Talk to Developers About Accessibility
jct
2
160
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
How STYLIGHT went responsive
nonsquared
100
6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
160
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.5k
4 Signs Your Business is Dying
shpigford
187
22k
Mobile First: as difficult as doing things right
swwweet
225
10k
Bash Introduction
62gerente
615
210k
Navigating Team Friction
lara
192
16k
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
いかがでしたか??? ありがとうございました