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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tomoki Ota
August 02, 2024
Programming
63
0
Share
【Go言語】名前付き戻り値
Go言語の名前付き戻り値の違いについて、解説しています。
【Qiita】
https://qiita.com/twrcd1227/items/2b6506ad57d3dc0b12d1
Tomoki Ota
August 02, 2024
More Decks by Tomoki Ota
See All by Tomoki Ota
アーキテクチャの価値
tomo1227
0
120
アーキテクチャとビジネスロジック
tomo1227
0
120
【Go言語】テスト
tomo1227
0
87
【Go言語】クロージャ
tomo1227
0
320
【Go言語】イテレータ
tomo1227
0
110
【Go言語】エラーハンドリング
tomo1227
0
90
AIに淘汰されないようにするには?
tomo1227
0
90
【Go言語】range
tomo1227
0
100
【Go言語】break
tomo1227
0
91
Other Decks in Programming
See All in Programming
The NotImplementedError Problem in Ruby
koic
1
340
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
850
エージェンティックRAGにAWSで入門しよう!
har1101
5
110
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
110
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
420
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
130
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
190
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
690
Lessons from Spec-Driven Development
simas
PRO
0
130
ふつうのFeature Flag実践入門
irof
7
3.5k
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
120
Featured
See All Featured
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Typedesign – Prime Four
hannesfritz
42
3.1k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Design in an AI World
tapps
1
220
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Claude Code のすすめ
schroneko
67
220k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Accessibility Awareness
sabderemane
1
130
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
Transcript
Tomoki Ota ʲGoݴޠʳ໊લ͖Γ
໊લ͖Γͱʁ ໊લ͖Γͷ༻ྫ ແҙຯͳ໊લ͖Γ ՄಡੑҎ֎ͷ໊લ͖Γ ۭreturn ໊લ͖Γͷ෭࡞༻ ·ͱΊ ΞδΣϯμ
໊લ͖Γͱʁ
GoͰ໊લ͖Γ(Named Return Value) ͋·ΓΘΕͳ͍ ໊લ͖Γͱʁ
໊લ͖ΓΛ͏ͱɺҾͳ͠ͷۭreturnจΛݺͼग़ͤΔ ໊લ͖Γͱʁ
໊લ͖Γͷ༻ྫ
໊લ͖Γͷ༻ྫ
໊લ͖Γͷ༻ྫ
ແҙຯͳ໊લ͖Γ
ແҙຯͳ໊લ͖Γ errorܕ͕errorͰ͋Δ͜ͱࣗ໌
ՄಡੑҎ֎ͷ໊લ͖Γ
ՄಡੑҎ֎ͷ໊લ͖Γ
ՄಡੑҎ֎ͷ໊લ͖Γ
ۭreturn
ۭreturn ۭreturnҰൠతʹ͍ؔͰ༻͍ΒΕΔɻ ͍ؔͰ༻͢ΔͱɺՄಡੑ͕ѱ͘ͳΔͷͰɺ༻ ͖͢Ͱͳ͍ɻ
ۭreturn 1ͭͷؔͰɺۭreturnΛ͏͔ɺҾͷ͋Δ returnΛ༻͢Δ͔Ұ؏ੑΛอͭ͜ͱ͕େࣄɻ
໊લ͖Γͷ෭࡞༻
໊લ͖Γͷ෭࡞༻ ໊લ͖ΓɺθϩͰॳظԽ͞ΕΔͷͰɺҙਤ ͠ͳ͍όάΛট͘Մೳੑ͕͋Δ
໊લ͖Γͷ෭࡞༻ ઌ΄ͲͷgetCoordinatesΛ֦ ு͠ɺॅॴΛݕূͯ͠ɺ࠲ඪΛ औಘ͢Δɻ·ͨɺ్தͰɺί ϯςΩετͰɺσουϥΠϯ͕ ա͗ͯͳ͍͔Ωϟϯηϧ͞ Ε͍ͯͳ͍͔Λݕࠪ͢Δɻ
໊લ͖Γͷ෭࡞༻ if ctx.Err() != nilͰฦ͞ΕΤ ϥʔerr͕ͩɺerrʹԿ ೖ͓ͯ͠ΒͣɺθϩͰ͋Δ nil͔͠ฦ͞ͳ͍ɻ
໊લ͖Γͷ෭࡞༻ err໊લ͖ΓʹΑͬͯ ॳظԽ͍ͯ͠ΔͷͰɺ໊લ͖ Γ͕ͳ͚ΕɺίϯύΠϧ ΤϥʔͱͳΔɻ
ղܾ๏1
ղܾ๏2