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
testingを眺める
matumoto
1
180
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
650
Goトランザクション処理
matumoto
1
70
いまいちどスライスの 挙動を見直してみる
matumoto
0
380
Go1.22のリリース予定の機能を見る
matumoto
0
76
Typed-nilについて
matumoto
0
350
GoのType Setsという概念
matumoto
0
40
GoのRateLimit処理の実装
matumoto
0
450
Webプッシュ通知触ってみた
matumoto
0
39
Other Decks in Technology
See All in Technology
Generative UI を試そう!A2-UIでAIエージェントにダッシュボードを作らせてみた
kamoshika
1
290
AI時代のAPIファースト開発
nagix
1
430
AITuberKit+Bedrock AgentCoreで作る 3Dキャラクターエージェント
yokomachi
2
1.5k
意志を実装するアーキテクチャモダナイゼーション
nwiizo
3
1.6k
Interop Tokyo 2025 ShowNet Team Memberで学んだSRv6を基礎から丁寧に
miyukichi_ospf
0
150
失敗できる意思決定とソフトウェアとの正しい歩き方_-_変化と向き合う選択肢/ Designing for Reversible Decisions
soudai
PRO
7
340
opsmethod第1回_アラート調査の自動化にむけて
yamatook
0
270
技術書を出版するまでの1161時間50分38秒
kakeami
0
150
器用貧乏が強みになるまで ~「なんでもやる」が導いたエンジニアとしての現在地~
kakehashi
PRO
5
480
Scrum Fest Morioka 2026
kawaguti
PRO
2
580
もう怖くないバックグラウンド処理 Background Tasks のすべて - Hakodate.swift #1
kantacky
0
100
OCI技術資料 : 外部接続 VPN接続 詳細
ocise
1
10k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
230
WENDY [Excerpt]
tessaabrams
9
36k
A Soul's Torment
seathinner
5
2.3k
WCS-LA-2024
lcolladotor
0
470
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
63
53k
So, you think you're a good person
axbom
PRO
2
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
320
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
140
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
いかがでしたか??? ありがとうございました