Skip to content

Instantly share code, notes, and snippets.

@thescubageek
Created February 17, 2016 16:33
Show Gist options
  • Save thescubageek/fa61ed31a6b39e63df54 to your computer and use it in GitHub Desktop.
Save thescubageek/fa61ed31a6b39e63df54 to your computer and use it in GitHub Desktop.
File to Array - Ruby
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