---
title: "Write better code and be a better programmer by NEVER USING ELSE statements"
url: https://daily.dev/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements-vpfhwwuko
source_url: https://dglsparsons.hashnode.dev/write-better-code-and-be-a-better-programmer-by-never-using-else-statements
type: article
source: "Hashnode"
author: "Douglas Parsons"
published: 2020-11-11T05:46:26.822Z
updated: 2021-10-07T14:17:10.317Z
tags: ["general-programming"]
reading_time: 6
upvotes: 41
comments: 4
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Write better code and be a better programmer by NEVER USING ELSE statements

**[Hashnode](https://daily.dev/sources/hashnode)** · [@dgls](https://daily.dev/dgls) · 6 min read · 41 upvotes · 4 comments

## Summary

The Art of Computer Programming is a book by Donald Knuth. In it, Knuth explains how to avoid using else statements in your code. Else statements break the line-of-sight rule, and they always lack context. Here, we show how to remove else statements from your code in two ways.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dglsparsons.hashnode.dev/write-better-code-and-be-a-better-programmer-by-never-using-else-statements>

## Community discussion

Top comments from developers on daily.dev.

**@hunterp** · 4 upvotes

> Great clickbait....and you clearly have thought it through well....but its going to take a LOT more to convince me an else statement is not the bedrock of defensive programming! ;-)

**@krook1024** · 2 upvotes

> never use else, use helper functions instead so ur code is more readable

**@tolis659** · 2 upvotes

> Clickbait and straight-up toxic gatekeeping bullshit.

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming)

[View this post on daily.dev](https://daily.dev/posts/write-better-code-and-be-a-better-programmer-by-never-using-else-statements-vpfhwwuko)
