Hacker News new | ask | show | jobs
by blcknight 3882 days ago
Ruby example is not very idiomatic. Give File.open a block and it'll handle closing it. Instead of flushing the file every time, you could just set file.sync = true once.

Also, if one was going to use the ensure block, use nil? not '== nil'

1 comments

Similar quirks in the Python example. Opening the file should ideally be done with a "with" statement to close the file automatically at the end. But in the Ruby example the author at least closed the file instead of doing nothing as in the Python example. :)