On Fri, Feb 21, 2014 at 1:02 PM, Paul Robinson <lists / ruby-forum.com> wrote:

> I'd just like to know if using class variables in this way is likely to
> cause any problems?

Most people coming from other languages with class-vars are caught
off-guard by a big gotcha.  In Ruby, the parent classes share with
their subclasses not only the fact that the class-var exists, but
*it's the same var*.

You seem to be actually taking advantage of that, so that if for
instance I subclass Cheese into Stilton and Wensleydale and
instantiate a few of each, each individual object will have its own
unique @idnumber.  So, I'd say that *this particular* usage of it is
unlikely to cause problems.  But watch out for it in other contexts
where you might be used to "normal" class-var behavior from other
languages.

This is one of the things covered in the slides from my "Ruby Gotchas"
presentation, at:

  https://docs.google.com/presentation/d/1cqdp89_kolr4q1YAQaB-6i5GXip8MHyve8MvQ_1r6_s

> Secondly, from the little I've discovered so far, is it correct that
> there is no way to delete an object when it is no longer required?

Generally speaking, that is correct, at least without hacking the
interpreter.  Trust the garbage collector, or tweak its parameters if
need be.

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us);
FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014;
creator of Pull Request Roulette, at PullRequestRoulette.com.