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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
matumoto
November 04, 2023
Technology
230
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
410
testingを眺める
matumoto
1
200
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
740
Goトランザクション処理
matumoto
1
79
いまいちどスライスの 挙動を見直してみる
matumoto
0
400
Go1.22のリリース予定の機能を見る
matumoto
0
83
Typed-nilについて
matumoto
0
370
GoのType Setsという概念
matumoto
0
49
GoのRateLimit処理の実装
matumoto
0
480
Other Decks in Technology
See All in Technology
AI駆動開発でなんでもハンズオン環境をつくってみた
yoshimi0227
0
180
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.7k
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
140
オンコールの負荷軽減のためのBits Assistant 活用方法 / How to Use Bits Assistant to Reduce the Workload on On-Call Staff
sms_tech
1
350
大学生が本気でDatabricksを活用してDiscordサークルをデータ駆動させてみた
phantomjuju
1
300
基礎から解説!Icebergで紐解くSnowflake×Databricks連携の現在地
cm_yasuhara
0
410
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
190
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
200
GitHub Copilot CLIでWebアクセシビリティを改善した話
tomokusaba
0
140
Datadog 認定試験の概要と対策
uechishingo
0
210
大規模災害時でも高い信頼性を維持するアプリケーション基盤の実現/nikkei-tech-talk46
nikkei_engineer_recruiting
0
120
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
110
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
190
The Language of Interfaces
destraynor
162
26k
A Soul's Torment
seathinner
6
2.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
340
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
580
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
350
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
430
A better future with KSS
kneath
240
18k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Abbi's Birthday
coloredviolet
2
7.8k
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
いかがでしたか??? ありがとうございました