Menu

#3 Ruby File Access

open
nobody
None
5
2006-02-25
2006-02-25
Ari Pollak
No

The first example of Ruby File Access,
"File.open("/usr/local/widgets/data").each { ..."
shouldn't be used because the File is opened but never
closed. A better idiom for files is to use IO::foreach:

IO.foreach("filename.txt") { |line| puts line }

Discussion


Log in to post a comment.