Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
560
Goトランザクション処理
matumoto
1
58
いまいちどスライスの 挙動を見直してみる
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
Bedrock AgentCore Evaluationsで学ぶLLM as a judge入門
shichijoyuhi
2
250
フィッシュボウルのやり方 / How to do a fishbowl
pauli
2
390
意外と知らない状態遷移テストの世界
nihonbuson
PRO
1
260
AI との良い付き合い方を僕らは誰も知らない
asei
0
270
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
2
200
Claude Codeを使った情報整理術
knishioka
11
6.3k
Strands Agents × インタリーブ思考 で変わるAIエージェント設計 / Strands Agents x Interleaved Thinking AI Agents
takanorig
5
2.1k
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
770
100以上の新規コネクタ提供を可能にしたアーキテクチャ
ooyukioo
0
260
MariaDB Connector/C のcaching_sha2_passwordプラグインの仕様について
boro1234
0
1k
LayerX QA Night#1
koyaman2
0
260
まだ間に合う! Agentic AI on AWSの現在地をやさしく一挙おさらい
minorun365
17
2.8k
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Statistics for Hackers
jakevdp
799
230k
The Curse of the Amulet
leimatthew05
0
4.8k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
380
The World Runs on Bad Software
bkeepers
PRO
72
12k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
130
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.7k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
30
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
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
いかがでしたか??? ありがとうございました