On the advice of Code Academy founder Neal Sales-Griffin, I am going through The Well-Grounded Rubyist. So far, I am liking it more than the Pickaxe book.
I did have a bit of a hard time with part of chapter three understanding singleton methods and class methods. Partially because terms and concepts can get swapped between languages. In Ruby, a class method is the same thing as a static method in Java. In Java, a “singleton” refers to a class that is only instantiated one time, like a logger class. In Ruby, a “singleton” is a method that is created for an instance object that is not in the class definition, and that other instances of that class will not have.
Part of the chapter dealing with this stuff was a bit confusing for me. Partially because of the terminology swap between languages, and the terminology swap in the book. In Ruby, everything is an object. Even classes. A class is an object is a class is an object is a class etc etc etc. So he was talking about singletons for class methods of objects connected to the thigh bone. This can get pretty confusing in general. Justin Love has given a presentation on it, and he compares it to the movie Inception, where you can have dreams within dreams.
I like Ruby, but changing existing class definitions (instead of just extending) seems like voodoo. I know Rails does it, but right now it just sounds like something to avoid.
After I get through this, I will go through Eloquent Ruby. A few people on Twitter have said that is a good combination.
Image from the Rheinau Psalter, a 13th century manuscript housed at Central Library of Zurich. Image from e-Codices. This image is assumed to be allowed under Fair Use.