<%unless (@students.empty? and params[:commit].nil?) %>
<%=“test”%>
<%= render :partial => ‘results’ %>
<% end %>
Even though in some cases @students.empty? returns false and params
[:commit].nil? returns true (or the opposite), it displays the test
and the render area.
I put before and after the code the <%=params[:commit].nil?%> and <
%[email protected]?%> so I can see it (it shows false and true or the
opposite and always it shows the render area and the test). I also
tried && but it was the same problem.
puts “Render” unless(true && false) # Prints Render
puts “Render” unless(true || false) # Does not print
puts “Render” unless(false || true) # Does not print
puts “Render” unless(true || true) # Does not print
puts “Render” unless(false || false) # Prints render (which is what
you want)
I think Jeffrey is right, “unless” with complex logic is just too
difficult for most of us to get our brains round easily.
You just insulted thousands of Perl programmers.
But seriously… it’s just the opposite of “if”.
Easy is the opposite of Difficult
Maybe I should not have said ‘most of us’ but certainly it applies to
me. There is a similar problem with variables with names like
not_valid, it is too easy to overload the brain when included in a
logical expression.
Oops! Yes indeed  I need an “or” instead of “and”, how I missed
that?? Thank you all for your help and the advices!
I think Jeffrey is right, “unless” with complex logic is just too
difficult for most of us to get our brains round easily. I avoid it
except in trivially simple cases.
I think Jeffrey is right, “unless” with complex logic is just too
difficult for most of us to get our brains round easily.
You just insulted thousands of Perl programmers.
But seriously… it’s just the opposite of “if”.
Easy is the opposite of Difficult
I agree. Even in Perl, many people consider unless poor style.
Maybe I should not have said ‘most of us’ but certainly it applies to
me. There is a similar problem with variables with names like
not_valid, it is too easy to overload the brain when included in a
logical expression.
Quite. Never forget to avoid omitting to eschew expressing things in
anything other than non-excessively negative form.