Ruby - File IOWhich 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")Check Answer
Step-by-Step SolutionSolution:Step 1: Understand directory existence checkRuby provides Dir.exist? method to check if a directory exists. Dir.exist?("folder_name") returns true if the directory exists, false otherwise.Final Answer:Dir.exist?("folder_name") -> Option CQuick 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 existConfusing Dir.exist? with Dir.mkdirUsing Dir.check? which is invalid
Master "File IO" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Blocks, Procs, and Lambdas - Block parameters - Quiz 11easy Class Methods and Variables - Class variables (@@) and their dangers - Quiz 13medium Class Methods and Variables - Class methods with self prefix - Quiz 11easy Classes and Objects - Self keyword behavior - Quiz 3easy Classes and Objects - Instance methods - Quiz 10hard File IO - IO modes (r, w, a) - Quiz 6medium Inheritance - Subclass with < operator - Quiz 2easy Inheritance - Is_a? and kind_of? for type checking - Quiz 6medium Modules and Mixins - Comparable module usage - Quiz 6medium Modules and Mixins - Prepend for method chain insertion - Quiz 10hard