Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
520
Goトランザクション処理
matumoto
1
53
いまいちどスライスの 挙動を見直してみる
matumoto
0
360
Go1.22のリリース予定の機能を見る
matumoto
0
69
Typed-nilについて
matumoto
0
340
GoのType Setsという概念
matumoto
0
32
GoのRateLimit処理の実装
matumoto
0
420
Webプッシュ通知触ってみた
matumoto
0
36
Other Decks in Technology
See All in Technology
AIにおける自由の追求
shujisado
2
460
こがヘンだよ!Snowflake?サービス名称へのこだわり
tarotaro0129
0
110
翻訳・対話・越境で強いチームワークを作ろう! / Building Strong Teamwork through Interpretation, Dialogue, and Border-Crossing
ar_tama
4
1.5k
Oracle Cloud Infrastructure:2025年11月度サービス・アップデート
oracle4engineer
PRO
1
110
「え?!それ今ではHTMLだけでできるの!?」驚きの進化を遂げたモダンHTML
riyaamemiya
9
4.3k
原理から解き明かす AIと人間の成長 - Progate BAR
teba_eleven
2
290
Kill the Vibe?Architecture in the age of AI
stoth
1
170
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
37k
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
21k
MySQL AIとMySQL Studioを使ってみよう
ikomachi226
0
130
Master Dataグループ紹介資料
sansan33
PRO
1
4k
Featured
See All Featured
How GitHub (no longer) Works
holman
316
140k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Rails Girls Zürich Keynote
gr2m
95
14k
BBQ
matthewcrist
89
9.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Optimizing for Happiness
mojombo
379
70k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Git: the NoSQL Database
bkeepers
PRO
432
66k
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
いかがでしたか??? ありがとうございました