Check that file exists: Difference between revisions

Content added Content deleted
(→‎{{header|UNIX Shell}}: Add a program to print the results.)
(→‎{{header|Ruby}}: Clarify meaning of File.exists?. The previous edit had stopped using File.exists? and started using File.file? and File.directory?.)
Line 804: Line 804:


=={{header|Ruby}}==
=={{header|Ruby}}==
<code>File.exists?</code> only checks if a file exists; <code>File.file?</code> or <code>File.directory?</code> checks for a regular file or a directory. Ruby also allows <code>FileTest.file?</code> or <code>FileTest.directory?</code>.
<code>File.exists?</code> only checks if a file exists; it can be a regular file, a directory, or something else. <code>File.file?</code> or <code>File.directory?</code> checks for a regular file or a directory. Ruby also allows <code>FileTest.file?</code> or <code>FileTest.directory?</code>.


<lang ruby>File.file?("input.txt")
<lang ruby>File.file?("input.txt")