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言語】値の比較
Search
Tomoki Ota
August 15, 2024
Programming
0
33
【Go言語】値の比較
値の比較について解説しています
Tomoki Ota
August 15, 2024
Tweet
Share
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
53
アーキテクチャとビジネスロジック
tomo1227
0
58
【Go言語】テスト
tomo1227
0
32
【Go言語】クロージャ
tomo1227
0
220
【Go言語】イテレータ
tomo1227
0
39
【Go言語】エラーハンドリング
tomo1227
0
41
AIに淘汰されないようにするには?
tomo1227
0
37
【Go言語】range
tomo1227
0
31
【Go言語】break
tomo1227
0
39
Other Decks in Programming
See All in Programming
GitHub Copilot for Azureを使い倒したい
ymd65536
1
310
Orleans + Sekiban + SignalR でリアルタイムWeb作ってみた
tomohisa
0
230
Optimizing JRuby 10
headius
0
560
プロダクトエンジニアのしごと 〜 受託 × 高難度を乗り越えるOptium開発 〜
algoartis
0
150
Boost Your Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
750
fieldalignmentから見るGoの構造体
kuro_kurorrr
0
130
Ruby on Railroad: The Power of Visualizing CFG
ydah
0
290
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
6
1.5k
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
2
950
SwiftDataのカスタムデータストアを試してみた
1mash0
0
140
The Implementations of Advanced LR Parser Algorithm
junk0612
1
1.3k
スモールスタートで始めるためのLambda×モノリス(Lambdalith)
akihisaikeda
2
340
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
94
13k
Making Projects Easy
brettharned
116
6.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Practical Orchestrator
shlominoach
187
11k
Making the Leap to Tech Lead
cromwellryan
133
9.2k
How to train your dragon (web standard)
notwaldorf
91
6k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Six Lessons from altMBA
skipperchong
28
3.7k
Transcript
Tomoki Ota ʲGoݴޠʳͷൺֱ
ͷൺֱৗʹ==Λͬͯ ൺֱͰ͖ΔΘ͚Ͱͳ͍
ൺֱͰ͖Δྫ ൺֱͰ͖ͳ͍ྫ ൺֱՄೳͳΦϖϥϯυ ൺֱෆՄೳͳܕͷൺֱ ΞδΣϯμ 3
ൺֱͰ͖Δྫ
ൺֱͰ͖Δྫ 5
ൺֱͰ͖ͳ͍ྫ
ൺֱͰ͖ͳ͍ྫ 7
ൺֱՄೳͳΦϖϥϯυ
ൺֱՄೳͳΦϖϥϯυ 9 == ͱ !=ɺΦϖϥϯυ͕ൺֱՄೳ(comparable)ͷͱ͖ʹ༻Ͱ͖Δ
ൺֱՄೳͳΦϖϥϯυ 10 boolean (ܕɺුಈখܕɺෳૉܕ) จࣈྻ νϟωϧ ΠϯλʔϑΣΠε ϙΠϯλ ߏମͱྻ
ൺֱՄೳͳΦϖϥϯυ 11
ൺֱՄೳͳΦϖϥϯυ 12 structಉ༷ɺanyܕҙʂ
ൺֱෆՄೳͳܕͷൺֱ
ൺֱෆՄೳͳܕͷൺֱ 14 ඪ४ϥΠϒϥϦͷre f lectΛ༻͢Δ
ൺֱෆՄೳͳܕͷൺֱ 15 re f lect.DeepEqualؔ2ͭͷΛ࠶ؼతʹḷͬͯɺ2ͭͷཁૉ͕͍͠ ͔൱͔Λஅ͢Δɻ ͜ΕجຊσʔλܕɺྻɺߏମɺεϥΠεɺϚοϓɺϙΠϯλɺΠϯλʔ ϑΣΠεɺؔʹ༻Ͱ͖Δɻ
re f lect.DeepEqualͷྫ 16
re f lect.DeepEqualͷҙ 17 nilίϨΫγϣϯͱۭίϨΫγϣϯΛ۠ผ͢Δ(ϢʔεέʔεʹΑͬͯͱͳΔɻ ྫ͑2ͭͷΞϯϚʔγϟϧૢ࡞ͷ݁ՌΛൺֱ͍ͨ࣌͠) ϦϑϨΫγϣϯΛ͍ͬͯΔͷͰɺੑೳ্ͷϖφϧςΟ͕͋Δ ϕϯνϚʔΫͰɺ==ͷ100ഒ͍ύϑΥʔϚϯεɻຊ൪Ͱͬͯμϝ
ಠࣗͷൺֱϝιουΛ࣮͢Δ 18 ಠࣗͷൺֱϝιουΛ༻͢Δͱɺ ύϑΥʔϚϯε͕վળ͢Δɻ ࠨͷίʔυre f lect.DeepEqualͷ96ഒߴ
ϢχοτςετͰͷൺֱ 19 ϢχοτςετͰɺgo-cmptestifyͱ͍ͬͨ֎෦ϥΠϒϥϦΛ༻Ͱ͖Δɻ ͔͠͠ɺ࣮ߦ࣌ͷੑೳ͕ॏཁͳ߹ɺಠࣗͷؔΛ࣮͢Δ͜ͱ͕ϕετϓϥΫςΟεɻ
ͦͷ΄͔ͷൺֱؔ 20 ඪ४ϥΠϒϥϦʹɺbytes.Compareͱ͍͏2ͭͷbyteεϥΠεΛ ൺֱͰ͖ΔϥΠϒϥϦ͕ଘࡏ͢Δɻ ಠࣗͷؔΛ࣮͢Δલʹɺंྠͷ࠶ൃ໌Λ͍ͯ͠ͳ͍͜ͱΛ֬ೝ͢Δʂ
ൺֱՄೳͳΒ==, !=Λ͏ ύϑΥʔϚϯεΛؾʹ͠ͳ͍ͳΒre f lectionΛ༻͢Δ ύϑΥʔϚϯεΛؾʹ͢ΔͳΒಠ࣮ࣗ ಠ࣮ࣗ͢ΔલʹطଘͷϥΠϒϥϦ͕ଘࡏ͢Δ͔ௐΔ ·ͱΊ 21