From: Pete Elmore Date: 2005-07-15T07:22:10+09:00 Subject: Re: Difference between Class.new and class Levin Alexander wrote: > Hi, > > why do class definitions with the keyword "class" return nil and not > the class itself? > > >> class Foo > >> def foo > >> puts "in Foo" > >> end > >> end > => nil irb(main):001:0> class X irb(main):002:1> def y irb(main):003:2> puts "z" irb(main):004:2> end irb(main):005:1> self irb(main):006:1> end => X The class definition returns the result of the last statement, so you can put 'self' just before the end of the definition to get it to return the class. It's returning nil because def returns nil.