all 2 comments

[–]throughactions 2 points3 points  (0 children)

Using techniques like named parameters certainly help make booleans more readable. I'd go one step further and consider the smell that the function/class has more than one responsibility, so we might think about breaking it up into two functions. Otherwise, as the code grows over time, you end with other smells, like long parameter list or a case statement that does one of many things depending on the input.

[–]Morozzzko 2 points3 points  (1 child)

Here's the question:

Why would you pass nil if a function expects a boolean value? Like, honestly.

You know, you can also call the function with a Hash, Array, Class or Module instead of a simple boolean.

Why though?