Created
February 17, 2016 16:33
-
-
Save thescubageek/fa61ed31a6b39e63df54 to your computer and use it in GitHub Desktop.
File to Array - Ruby
This file contains 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
def file_to_array(file) | |
arr = [] | |
if File.exists?(file) | |
f = File.read(file) | |
f.each_line { |line| arr << line.strip unless line == "\n" } | |
end | |
arr | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment