What is the fastest, most optimized, one-liner way to get an array of the directories (excluding files) in Ruby?
How about including files?
What is the fastest, most optimized, one-liner way to get an array of the directories (excluding files) in Ruby?
How about including files?
Although not a one line solution, I think this is the best way to do it using ruby calls.
First delete all the files recursively
Second delete all the empty directories
In PHP or other languages to get the content of a directory and all its subdirectories, you have to write some lines of code, but in Ruby it takes 2 lines:
this will print the content of the current directory and all its subdirectories.
Or shorter, You can use the
’**’
notation :How many lines will you write in PHP or in Java to get the same result?
dots return nil, use compact