title: Lua ""==true equals ""==false
body: <p>I'm having trouble understanding how the expressions <code>""==true</code> and <code>""==false</code> both evaluate to <code>false</code>. </p>
  
  <p>Trying the following in the lua interpreter and ilua result in the same output:</p>
  
  <pre><code>&gt; =""==true
  false
  &gt; =""==false
  false
  </code></pre>
  
  <p>Or executing the following:</p>
  
  <pre><code>print(""==true)
  print(""==false)
  print(""==nil)
  </code></pre>
  
  <p>Outputs</p>
  
  <pre><code>Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  false
  false
  false
  &gt; 
  </code></pre>
  
  <p>Another example:</p>
  
  <pre><code>&gt; =""~=true
  true
  &gt; =""==false
  false
  </code></pre>
  
  <p>When the following code is run:</p>
  
  <pre><code>if "" then -- if ""==true
      print "was true"
  end 
  
  if not "" then -- if ""==false
      print "was not true"
  end 
  </code></pre>
  
  <p>The output is (seemingly inconsistently)</p>
  
  <pre><code>Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  was true
  &gt; 
  </code></pre>
  
  <p>As expected per the Lua FAQ which states</p>
  
  <blockquote>
    <p>C-like languages regard 0 as equivalent to false, but this is not true
    for Lua. Only an explicit false or nil are equivalent to false. When
    in doubt, make the condition explicit, e.g. if val == nil then ... end
    unless the value is actually boolean.</p>
  </blockquote>
  
  <p>How can a value be <em>not</em> equal to <code>true</code>,<code>false</code> or <code>nill</code>?</p>