Q:

Ruby program to remove a specified directory

0

In this program, we will remove a specified directory using Dir.rmdir() method.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to remove a specified directory is given below. The given program is compiled and executed on Windows 10 Operating System successfully.

# Ruby program to remove 
# a specified directory

puts Dir.exists?("mydir"); 

Dir.rmdir("mydir"); 

puts Dir.exists?("mydir");

Output:

true
false

Explanation:

In the above program, we used Dir.rmdir() method to remove the specified directory. Here we checked directory exists or not using Dir.exists?() method and print returned value.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now