Gio Lodi 9/14/2020

Replace Triple-state Boolean with Enumeration

Read Original

This article explores the problem of three-state Booleans (true, false, null) in software development, using examples from Ruby on Rails and Swift. It explains how nullable Booleans create ambiguity and potential runtime errors, then advocates for using enumerations (enums) to explicitly model states like true, false, and 'not asked' for clearer, more maintainable code.

Replace Triple-state Boolean with Enumeration

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week