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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
matumoto
November 04, 2023
Technology
220
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
380
testingを眺める
matumoto
1
190
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
690
Goトランザクション処理
matumoto
1
78
いまいちどスライスの 挙動を見直してみる
matumoto
0
390
Go1.22のリリース予定の機能を見る
matumoto
0
80
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
47
GoのRateLimit処理の実装
matumoto
0
470
Other Decks in Technology
See All in Technology
20260410 - CNTUG meetup #72 - DiskImage Builder 介紹:以 Kubespray CI 打造 RockyLinux 10 Cloud Image 為例
tico88612
0
120
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
160
ASTのGitHub CopilotとCopilot CLIの現在地をお話しします/How AST Operates GitHub Copilot and Copilot CLI
aeonpeople
1
220
暗黙知について一歩踏み込んで考える - 暗黙知の4タイプと暗黙考・暗黙動へ
masayamoriofficial
0
1.4k
2026年に相応しい 最先端プラグインホストの設計<del>と実装</del>
atsushieno
0
110
デシリアライゼーションを理解する / Inside Deserialization
tomzoh
0
260
すごいぞManaged Kubernetes
harukasakihara
1
390
試されDATA SAPPORO [LT]Claude Codeで「ゆっくりデータ分析」
ishikawa_satoru
0
370
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」ご紹介資料
laysakura
0
1.6k
新メンバーのために、シニアエンジニアが環境を作る時代
puku0x
0
710
Kubernetes基盤における開発者体験 とセキュリティの両⽴ / Balancing developer experience and security in a Kubernetes-based environment
chmikata
0
250
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
180
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.5k
A designer walks into a library…
pauljervisheath
211
24k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
490
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
KATA
mclloyd
PRO
35
15k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
My Coaching Mixtape
mlcsv
0
97
The Spectacular Lies of Maps
axbom
PRO
1
680
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Building Applications with DynamoDB
mza
96
7k
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
いかがでしたか??? ありがとうございました