Class.new returns object . class A returns nil . The same goes for module s.
It is not right. A class / module definition returns the value of the last expression evaluated inside the class / module body:
class Foo 42 end
Typically, the last expression evaluated inside the body of the class / module will be the expression of the method definition, which in current versions of Ruby returns Symbol representing the name of the method:
class Foo def bar; end end
In older versions of Ruby, the return value of the method definition expression was determined by the implementation. Rubinius returned a CompiledMethod object for the method in question, while YARV and most others simply returned nil .
source share