Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Created February 24, 2009 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithrbennett/69690 to your computer and use it in GitHub Desktop.
Save keithrbennett/69690 to your computer and use it in GitHub Desktop.
def file_to_nums(filespec)
file_content = IO.read filespec
numbers_as_strings = file_content.split ','
numbers_as_strings.map { |s| s.to_f}
end
`echo 1, 123, 74, 1.234 > numbers.txt`
p file_to_nums('numbers.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment