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 }
No refactoring yet !
Name
Email
Website
Comment
Format Copy from initial code Code
Notify me of new refactorings by email
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.