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
80
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
Go1.22のリリース予定の機能を見る
matumoto
0
34
Typed-nilについて
matumoto
0
48
GoのType Setsという概念
matumoto
0
4
GoのRateLimit処理の実装
matumoto
0
83
Webプッシュ通知触ってみた
matumoto
0
23
拡張ユークリッドの互除法の紹介
matumoto
0
46
Goでの楕円曲線暗号の実装
matumoto
0
25
インターン参加記
matumoto
0
20
インデックスのパフォーマンス調べてみた
matumoto
0
20
Other Decks in Technology
See All in Technology
非同期推論システムによるコスト削減と信頼性向上
koki_nishihara
1
360
MapLibreとAmazon Location Service
dayjournal
1
180
IaCジェネレーターとBedrockで詳細設計書を生成してみた
tsukasa_ishimaru
4
880
MLOpsの「壁」を乗り越える、LINEヤフーの Data Quality as Code
lycorptech_jp
PRO
8
620
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
3
620
Tellus の衛星データを見てみよう #mf_fukuoka
kongmingstrap
0
270
アクセス制御にまつわる改善 / Improving access control
itkq
0
590
Handling focus in 2024
tahia910
0
220
IPUT App Dev. Co. -Overview 2024/4
iputapp
0
120
Cypress or Playwright?
rainerhahnekamp
0
170
web-application-security
matsuihidetoshi
1
190
【基本】データベース設計
oracle4engineer
PRO
2
170
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
13
8.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
7
3.4k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.7k
What's new in Ruby 2.0
geeforr
337
31k
How GitHub (no longer) Works
holman
305
140k
Practical Orchestrator
shlominoach
183
9.7k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
The Invisible Side of Design
smashingmag
294
49k
Music & Morning Musume
bryan
41
5.6k
Being A Developer After 40
akosma
66
580k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
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
いかがでしたか??? ありがとうございました