Bird
0
0

Which Ruby method is used to check if a directory exists?

easy📝 Conceptual Q1 of 15
Ruby - File IO
Which Ruby method is used to check if a directory exists?
ADir.create?("folder_name")
BDir.check?("folder_name")
CDir.exist?("folder_name")
DDir.make?("folder_name")
Step-by-Step Solution
Solution:
  1. Step 1: Understand directory existence check

    Ruby provides Dir.exist? method to check if a directory exists. Dir.exist?("folder_name") returns true if the directory exists, false otherwise.
  2. Final Answer:

    Dir.exist?("folder_name") -> Option C
  3. Quick Check:

    Directory existence check = Dir.exist? [OK]
Quick Trick: Use Dir.exist? to check directory presence quickly [OK]
Common Mistakes:
  • Using Dir.create? which does not exist
  • Confusing Dir.exist? with Dir.mkdir
  • Using Dir.check? which is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes