To create a directory in Ruby, you can use the Dir.mkdir
method or the FileUtils.mkdir
method (which provides more advanced options and error handling). Here's an example using Dir.mkdir
:
main.rb50 chars3 lines
This will create a new directory with the name "my_new_directory" in the current working directory.
And here's an example using FileUtils.mkdir
:
main.rb76 chars4 lines
This will also create a new directory with the name "my_new_directory" in the current working directory, but FileUtils.mkdir
provides more options for handling errors and creating parent directories if they don't exist.
gistlibby LogSnag