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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
matumoto
November 04, 2023
Technology
220
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
370
testingを眺める
matumoto
1
190
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
680
Goトランザクション処理
matumoto
1
77
いまいちどスライスの 挙動を見直してみる
matumoto
0
390
Go1.22のリリース予定の機能を見る
matumoto
0
80
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
46
GoのRateLimit処理の実装
matumoto
0
470
Other Decks in Technology
See All in Technology
TUNA Camp 2026 京都Stage ヒューリスティックアルゴリズム入門
terryu16
0
650
OCI技術資料 : 証明書サービス概要
ocise
1
7.2k
マルチモーダル非構造データとの闘い
shibuiwilliam
1
130
How to install a gem
indirect
0
2k
Podcast配信で広がったアウトプットの輪~70人と音声発信してきた7年間~/outputconf_01
fortegp05
0
180
Even G2 クイックスタートガイド(日本語版)
vrshinobi1
0
190
MIX AUDIO EN BROADCAST
ralpherick
0
140
スクラムを支える内部品質の話
iij_pr
0
160
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
280
FASTでAIエージェントを作りまくろう!
yukiogawa
4
180
Kubernetesの「隠れメモリ消費」によるNode共倒れと、Request適正化という処方箋
g0xu
0
170
AIエージェント時代に必要な オペレーションマネージャーのロールとは
kentarofujii
0
270
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
310
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
700
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
230
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
250
The Language of Interfaces
destraynor
162
26k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
330
Abbi's Birthday
coloredviolet
2
6.2k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
250
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
94
So, you think you're a good person
axbom
PRO
2
2k
From π to Pie charts
rasagy
0
160
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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
いかがでしたか??? ありがとうございました