-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Versions
Elixir
$ elixir --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
Elixir 1.17.2 (compiled with Erlang/OTP 27)
Styler
$ mix deps | grep locked | grep styler
locked at 1.0.0 (styler) 4ba5bc40
Example Input
if env != :test do
# ...
endCurrent Behaviour
unless env == :test do
# ...
endProblem
We're about to upgrade styler to 1.x and I was shocked after checking what have changed after running the formatter π²
I know that Elixir has if and its negated version unless, but I really don't get why unless env == :test should be more readable than if env != :test π€ Just because it is there doesn't mean we need to use it.
When reading the code I first see env == :test and to know whether this is true or not I also need to look whether it is an if or unless clause. So, I always need to think about two things instead of just one when simply using a if-clause.
Maybe that's just because of how my brain works, especially because I never used unless before, but I would really like to know whether using unless is really better than having an if-clause with a negation.