This code structure is called an arrow anti-pattern. How to fix...

@codingandcatss
Coding and Cats@codingandcatss
12 views Jan 17, 2026 ~1 min read
Advertisement
1
This code structure is called an arrow anti-pattern. How to fix this code?
Media image
2
This is a solution. Switch statement is ok, too.
Media image
3
Alternative solution: This ensures that you don't get surprised by unordered way of dictionaries. "Unordered: The order of elements in a dictionary is not guaranteed. The elements are stored in a way that optimizes lookup performance, rather than maintaining a specific order."
Media image
4
Assume that you are giving E grade from now on. Above 25 is E grade. How did your code change? Mine? Not much.
Media image
5
Ultimate solution found!
Media image
6
If someone ask me to refactor the first "nonsense" code, I will use this way. Only thing I will change is white background of the code. Thanks @viniciuscgp
Media image
7
Hello there. Dictionary solution was wrong. It attracted more people so I didn't delete it. Sorry.
8
Hello there. 2.5 M views for the main post. Thank you all, but please let it go?
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement