From: Marnen Laibow-Koser Date: 2009-11-28T07:00:58+09:00 Subject: Re: Class variables, instance variables, singleton; Ruby v. Ralph Shnelvar wrote: > Newb here coming from C++ > > Ok, I _think_ I know what a class variable is. It is similar to a > static variable in a class in C++. Rght? Yes. > > An instance variable is apart of an instantiated class, right? Not an "instantiated class", but a class instance -- which pretty much describes everything in Ruby, since everything is an object. > > What's a singleton? I don't think it's the same as as singleton in > C++ parlance. But you are wrong. > > - - - > > If Class X wants to access a class variable and/or constant in Class Y, > must a class > method be defined For variables, yes. Constants are directly accessible. Remember, Ruby has no such thing as public data members in C++. > or is there a direct way to do it? Only for constants (you know, the Class::CONSTANT syntax). > > Besides the Pickaxe book, can anyone recommend a document that > describes this a bit more clearly? The Pickaxe book explains all this *very* clearly. > > - - - > > So I did a search for "ruby for c++ programmers." on Google and came > up with exactly one article > (http://californickation.blogspot.com/2008/02/first-look-at-ruby.html) > ... one that says "Another funny fact is that searching for "Ruby for > Java programmers" retrieves a few articles right on the first page while > "Ruby for C++ programmers" does not." > > Anyone know of any articles? Do you really need something like that? And if you do, won't the Java articles suffice? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.