How to simplify nested ifs
Public
19 Jun 08:44

If you have ifs nested in this way:

if a
  if b
    1
  else
    2
  end
else
  3
end

You can flatten and simplify them into this:

if !a
  3
elsif b
  1
else
  2
end

In other words, start with the simplest part and add more complex ones later.

#untagged

Comments

Empty! You must sign in to add comments.