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
44
【Go言語】値の比較
値の比較について解説しています
Tomoki Ota
August 15, 2024
Tweet
Share
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
95
アーキテクチャとビジネスロジック
tomo1227
0
94
【Go言語】テスト
tomo1227
0
53
【Go言語】クロージャ
tomo1227
0
260
【Go言語】イテレータ
tomo1227
0
70
【Go言語】エラーハンドリング
tomo1227
0
59
AIに淘汰されないようにするには?
tomo1227
0
59
【Go言語】range
tomo1227
0
64
【Go言語】break
tomo1227
0
63
Other Decks in Programming
See All in Programming
釣り地図SNSにおける有料機能の実装
nokonoko1203
0
200
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
3
850
AI駆動で0→1をやって見えた光と伸びしろ
passion0102
1
860
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
500
SODA - FACT BOOK(JP)
sodainc
1
8.8k
When Dependencies Fail: Building Antifragile Applications in a Fragile World
selcukusta
0
110
Devvox Belgium - Agentic AI Patterns
kdubois
1
150
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
510
ドメイン駆動設計のエッセンス
masuda220
PRO
7
1.5k
What's new in Spring Modulith?
olivergierke
1
170
AI Agent 時代的開發者生存指南
eddie
4
2.1k
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
260
Featured
See All Featured
BBQ
matthewcrist
89
9.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.5k
Statistics for Hackers
jakevdp
799
220k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Thoughts on Productivity
jonyablonski
70
4.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
The Language of Interfaces
destraynor
162
25k
It's Worth the Effort
3n
187
28k
Building Applications with DynamoDB
mza
96
6.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