memesearch
Go Error Check Fallthrough

Go Error Check Fallthrough

Download Find similar pictures
Text on the meme
> Asks if 'if err != nil' is really that bad > Screenshot example shows accidental fallthrough from error case to success case Do we really need to discuss further? is 'if err != nil' really that bad? match atoi "6942" with | Error -> Printf.printf "failed to parse int\n" | Ok n -> Printf.printf "hello %d\n" n n, err := atoi("6942") if err != nil { fmt.Printf("failed to parse int\n") } fmt.Printf("hello %d\n", n)
What it means

A programming meme contrasts pattern matching in a functional language with Go's explicit error check. The Go example prints the success message even after parsing fails because execution falls through after the error branch, making the criticism of `if err != nil` look obviously justified. It is shared as a sarcastic reaction to debates about Go error handling. EN: A programming meme contrasts pattern matching in a functional language with Go's explicit error check. The Go example prints the success message even after parsing fails because execution falls through after the error branch, making the criticism of `if err != nil` look obviously justified. It is shared as a sarcastic reaction to debates about Go error handling.

Objects
Tags
Source
Type
image
Size
781×800 · 74.9 KiB
Mood
sarcastic
Language
en
Added