It's amazing now, working with Ruby, how needlessly complicated the language is.
You have objects. And you have methods. So you declare these methods on the class of that Object.
But then you have the reflection API. And now you need .instance_method, that captures an UnboundMethod from the class, or .method which captures a Method from the instance
Sure, but classes can have methods (they are called static methods in Java). So you declare them... in classes. But the class is the instance. So you now have a .singleton_class methods that lazily creates a "class" for the "class" of an "object".
Also, inside the class but outside a method is a valid place to run code - so you can define an API that dynamically declares methods too, and they can be bound to a different class than the one you're running now...
Finally, there are at least two ways of declaring methods - both declare new scopes, but one is also a closure, which keeps variables from outside your method declaration. Good luck finding reason around that...
Ruby is a write-only language
Well, although I tend to agree at some point, Clojure can be worse. My last experiences with it were kinda like I was working on a meta-language written over Clojure, to the point that Ruby is feeling way better honestly... I still prefer Clojure the language, but I am not sure about working with it (unless I am sure I won't find weird stuff)
don't forget about modules and how those apply to the class hierarchy!
include, extend, prepend, please_make_it_stop
and dynamically created modules made with Module.new that have methods added to them then the module is prepended so you don't have to pollute the class directly and the user can override the method and just call super to call into the dynamic module's methods
ð ð ð
Also remember that extend can be applied to instances too ðą
and you can include and extend and prepend on singleton classes ðĪŠ