Skip to content

Instantly share code, notes, and snippets.

@davidnunez
Created March 8, 2012 16:18
Show Gist options
  • Save davidnunez/2001851 to your computer and use it in GitHub Desktop.
Save davidnunez/2001851 to your computer and use it in GitHub Desktop.
Ruby: getting random line from file
line = IO.readlines('some_file')
c = rand*line.length.to_i
puts line[c-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment