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
60
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
84
【Go言語】クロージャ
tomo1227
0
320
【Go言語】イテレータ
tomo1227
0
110
【Go言語】エラーハンドリング
tomo1227
0
88
AIに淘汰されないようにするには?
tomo1227
0
87
【Go言語】range
tomo1227
0
97
【Go言語】break
tomo1227
0
87
Other Decks in Programming
See All in Programming
書き換えて学ぶTemporal #fukts
pirosikick
2
350
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.1k
継続的な負荷検証を目指して
pyama86
0
310
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.6k
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
6
1.5k
t *testing.T は どこからやってくるの?
otakakot
1
900
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
190
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
1.4k
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
310
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.8k
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
210
Making the RBS Parser Faster
soutaro
0
660
Featured
See All Featured
The Language of Interfaces
destraynor
162
26k
Test your architecture with Archunit
thirion
1
2.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Marketing to machines
jonoalderson
1
5.2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
530
Building Adaptive Systems
keathley
44
3k
How to Talk to Developers About Accessibility
jct
2
190
Mobile First: as difficult as doing things right
swwweet
225
10k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
340
Crafting Experiences
bethany
1
140
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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