If you were like me, your eyes would just glaze over when reading programming books. "OK," you'd say, "but how is that useful?" This article is the first in a series of "worked examples," articles that feature working example programs and explain the Ruby features that make it tick. It starts off simple, with a number guessing game (that I'm sure many if you have already written if you've learned other programming languages).
Imagine you want to keep tabs on an object, but that object takes a lot of memory. If you were to save a reference to that object, the garbage collector cannot deallocate that memory. The WeakRef class allows you to use weak references to watch objects without actually keeping references to them. This is not without caveats though.
Are you new to Ruby? Or even new to programming in general? This article tries to answer this question as simply as possible, in plain english and without buzzwords.
How large is a file? When was it last modified? These are types of things that can't be (or are difficult to be) answered by querying a File object. However, the File::Stat class can be used to gather such information, as well as a variety of other statistics.