$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GoのUnderlying typeについて
Search
matumoto
November 04, 2023
Technology
0
210
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
170
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
550
Goトランザクション処理
matumoto
1
56
いまいちどスライスの 挙動を見直してみる
matumoto
0
360
Go1.22のリリース予定の機能を見る
matumoto
0
70
Typed-nilについて
matumoto
0
350
GoのType Setsという概念
matumoto
0
33
GoのRateLimit処理の実装
matumoto
0
430
Webプッシュ通知触ってみた
matumoto
0
38
Other Decks in Technology
See All in Technology
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
18
7.5k
100以上の新規コネクタ提供を可能にしたアーキテクチャ
ooyukioo
0
240
『君の名は』と聞く君の名は。 / Your name, you who asks for mine.
nttcom
1
110
Knowledge Work の AI Backend
kworkdev
PRO
0
150
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
760
Agent Skillsがハーネスの垣根を超える日
gotalab555
6
3.8k
SREが取り組むデプロイ高速化 ─ Docker Buildを最適化した話
capytan
0
130
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
2
1.5k
AI with TiDD
shiraji
1
260
AWSの新機能をフル活用した「re:Inventエージェント」開発秘話
minorun365
2
410
20251219 OpenIDファウンデーション・ジャパン紹介 / OpenID Foundation Japan Intro
oidfj
0
450
たまに起きる外部サービスの障害に備えたり備えなかったりする話
egmc
0
390
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
86
Mind Mapping
helmedeiros
PRO
0
38
Writing Fast Ruby
sferik
630
62k
Abbi's Birthday
coloredviolet
0
3.6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
The Invisible Side of Design
smashingmag
302
51k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
How to make the Groovebox
asonas
2
1.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
330
My Coaching Mixtape
mlcsv
0
13
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
いかがでしたか??? ありがとうございました