1945ab4cdb87eaf5a5c906fa884c29f1

My first Ruby script. I'm curious how to improve it.

Funnily enough, I was stymied by the while/for syntax. So, I used the more functional style.

1
2
3
4
#!/usr/bin/env ruby

files = ARGV.collect { |fname| File.new(fname, 'w') }
$stdin.each { |line| files[rand(files.length)].puts line }

Refactorings

No refactoring yet !

Your refactoring





Format Copy from initial code

or Cancel