In my last post I wrote that providing a home for class methods was the raison d’être of the Metaclass. So why go through all the trouble? What are class methods good for? Four uses worth exploring are Object Creation, Annotations, DSL’s, and removal of structural duplication
This post is about Ruby class […]
Archive for the 'Smalltalk' Category
Class Methods
«
19 October 2007 |
11:34 |
patterns/idiom/style, Smalltalk, Ruby Internals, MRI |
2 Comments »
Real Class
«
28 September 2007 |
8:23 |
Smalltalk, JRuby, Ruby Internals, MRI |
5 Comments »
It interesting that Ruby, a language which allows you to so easily bypass encapsulation, encapsulates it’s own internals to the point of occasional prevarication. Heres an example…
pirate = Object.new
def pirate.speak
“Yarrrr”
end
pirate.class == Object.new.class
#=> true
In my last post I explained how the code above forces the interpreter to assign a newly created Singleton class to the […]
It interesting that Ruby, a language which allows you to so easily bypass encapsulation, encapsulates it’s own internals to the point of occasional prevarication. Heres an example…
pirate = Object.new
def pirate.speak
“Yarrrr”
end
pirate.class == Object.new.class
#=> true
In my last post I explained how the code above forces the interpreter to assign a newly created Singleton class to the […]