Don N. wrote:
Did a search on URL so do not believe this has been posted before.
This is a decent resource, but just beware that some of it is
non-idiomatic or misleading (in my opinion). For example, why is the 4th
example using global variables? In the 12th example, why are there
blocks after “if”?
Some of the file examples do not close the file and while this is
addressed, none of the examples use the much more common
File.open “filename” do |f|
which ensures the file is closed for you.
In example 22, there is this:
rescue TruncatedDataError #the last read had less chars than specified
#print the rest of the data. $! is the exception.
“.data” has the extra bytes
I have never seen $! used, especially in this situation where one would
rescue TruncatedDataError => err
In example 37, the code shown is
when you should almost never be seeing camelcase for file names. (JRuby
might be the exception)
I don’t mean to pick on the author of the page (clearly they put a lot
of work into this), I just want you to be careful when emulating the
code on there.