Created
April 10, 2014 08:34
-
-
Save danimal141/10356775 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before | |
def get_file_names path | |
file_names = [] | |
Dir.glob(path).each do |file| | |
file_names << File.basename(file) if File::ftype(file) == "file" | |
end | |
return file_names | |
end | |
# After Refactoring | |
def get_file_names path | |
[].tap do |file_names| | |
Dir.glob(path).each do |file| | |
file_names << File.basename(file) if File::ftype(file) == 'file' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment