title: How to check if a given directory exists in Ruby
body: <p>I am trying to write a script which automatically checks out or updates a Subversion URL based on whether a specified directory exists or not.</p>
  
  <p>For some reason, my code isn't working and always returns <em>true</em> even if it's false:</p>
  
  <pre><code>def directory_exists?(directory)
    return false if Dir[directory] == nil
    true
  end
  </code></pre>
  
  <p>What am I doing wrong?</p>